From c074a6166c38eb836289a01841028f3616b451c3 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 29 Jun 2017 15:16:43 +0200 Subject: [PATCH] enable some warnings & fix 'em --- Makefile.am | 2 +- examples/vcard.c | 2 +- src/stanza.c | 4 ++-- tests/test_base64.c | 3 +-- tests/test_string.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index dce5560..c58bc4f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ SSL_LIBS = @openssl_LIBS@ RESOLV_LIBS = @RESOLV_LIBS@ -STROPHE_FLAGS = -I$(top_srcdir) +STROPHE_FLAGS = -I$(top_srcdir) -Wall -Wextra -Werror -Wno-unused-parameter STROPHE_LIBS = libstrophe.la ## Main build targets diff --git a/examples/vcard.c b/examples/vcard.c index c584063..b84d25e 100644 --- a/examples/vcard.c +++ b/examples/vcard.c @@ -131,7 +131,7 @@ static vcard_cb_t vcard_cb_get(xmpp_stanza_t *stanza) { vcard_cb_t cb = NULL; const char *tag; - int i; + size_t i; static struct { const char *tag; diff --git a/src/stanza.c b/src/stanza.c index db70bf3..7a15521 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -431,7 +431,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza, ret = _render_stanza_recursive(stanza, buffer, length); if (ret < 0) return ret; - if (ret > length - 1) { + if ((size_t)ret > length - 1) { tmp = xmpp_realloc(stanza->ctx, buffer, ret + 1); if (!tmp) { xmpp_free(stanza->ctx, buffer); @@ -443,7 +443,7 @@ int xmpp_stanza_to_text(xmpp_stanza_t *stanza, buffer = tmp; ret = _render_stanza_recursive(stanza, buffer, length); - if (ret > length - 1) return XMPP_EMEM; + if ((size_t)ret > length - 1) return XMPP_EMEM; } buffer[length - 1] = 0; diff --git a/tests/test_base64.c b/tests/test_base64.c index 6e7697f..613d1c8 100644 --- a/tests/test_base64.c +++ b/tests/test_base64.c @@ -134,8 +134,7 @@ int main(int argc, char *argv[]) unsigned char *udec; char *dec; char *enc; - size_t len; - int i; + size_t len, i; printf("BASE64 tests.\n"); diff --git a/tests/test_string.c b/tests/test_string.c index fc1b391..a28d001 100644 --- a/tests/test_string.c +++ b/tests/test_string.c @@ -79,7 +79,7 @@ static int test_strdup_one(xmpp_ctx_t *ctx, const char *s) static int test_strdup(void) { xmpp_ctx_t *ctx; - int i; + size_t i; int rc = 0; static const char *tests[] = { "", "\0", "test", "s p a c e", "\n\r" };