add some more warning CFLAGS, inspired by Benjamin Otte's blog post,
authorDan Winship <danw@src.gnome.org>
Tue, 23 Dec 2008 19:05:12 +0000 (19:05 +0000)
committerDan Winship <danw@src.gnome.org>
Tue, 23 Dec 2008 19:05:12 +0000 (19:05 +0000)
* configure.in: add some more warning CFLAGS, inspired by Benjamin
Otte's blog post, although none of them picked out any actual
bugs. Annoyingly, the most interesting warnings came from
-Wwrite-strings and -Wshadow, both of which I decided against
keeping, because they had too many false positives.

* libsoup/soup-cookie-jar.c (soup_cookie_jar_get_cookies): rename
a variable to avoid shadowing.

* libsoup/soup-message-headers.c
(soup_message_headers_get_ranges): move a variable declaration to
avoid a possibly-confusing shadowing.

* tests/forms-test.c:
* tests/header-parsing.c:
* tests/range-test.c:
* tests/test-utils.c: constify some "char *"s that should have
already been const.

* tests/get.c (find_hrefs): rename an arg whose name shadowed a
global, to avoid possible future confusion
(get_url): Likewise with a functional-internal shadowing.

svn path=/trunk/; revision=1222

ChangeLog
configure.in
libsoup/soup-cookie-jar.c
libsoup/soup-message-headers.c
tests/forms-test.c
tests/get.c
tests/header-parsing.c
tests/range-test.c
tests/test-utils.c

index 49acb0f..bb3a077 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2008-12-23  Dan Winship  <danw@gnome.org>
+
+       * configure.in: add some more warning CFLAGS, inspired by Benjamin
+       Otte's blog post, although none of them picked out any actual
+       bugs. Annoyingly, the most interesting warnings came from
+       -Wwrite-strings and -Wshadow, both of which I decided against
+       keeping, because they had too many false positives.
+
+       * libsoup/soup-cookie-jar.c (soup_cookie_jar_get_cookies): rename
+       a variable to avoid shadowing.
+
+       * libsoup/soup-message-headers.c
+       (soup_message_headers_get_ranges): move a variable declaration to
+       avoid a possibly-confusing shadowing.
+
+       * tests/forms-test.c:
+       * tests/header-parsing.c:
+       * tests/range-test.c:
+       * tests/test-utils.c: constify some "char *"s that should have
+       already been const.
+
+       * tests/get.c (find_hrefs): rename an arg whose name shadowed a
+       global, to avoid possible future confusion
+       (get_url): Likewise with a functional-internal shadowing.
+
 2008-12-09  Dan Winship  <danw@gnome.org>
 
        * libsoup/soup-uri.c (soup_uri_new): Explicitly document the fact
index 14a899e..d0ffb1a 100644 (file)
@@ -235,7 +235,10 @@ AC_ARG_ENABLE(more-warnings,
 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
        CFLAGS="$CFLAGS \
                -Wall -Wstrict-prototypes -Wmissing-declarations \
-               -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+               -Wmissing-prototypes -Wnested-externs -Wpointer-arith \
+               -Wdeclaration-after-statement -Wformat=2 -Winit-self \
+               -Wmissing-include-dirs -Wundef -Waggregate-return \
+               -Wmissing-format-attribute"
 fi
 
 if test "$os_win32" != yes; then
index b3d02be..243c215 100644 (file)
@@ -252,7 +252,7 @@ soup_cookie_jar_get_cookies (SoupCookieJar *jar, SoupURI *uri,
 {
        SoupCookieJarPrivate *priv;
        GSList *cookies, *domain_cookies;
-       char *domain, *cur, *next, *result;
+       char *domain, *cur, *next_domain, *result;
        GSList *new_head, *cookies_to_remove = NULL, *p;
 
        g_return_val_if_fail (SOUP_IS_COOKIE_JAR (jar), NULL);
@@ -265,7 +265,7 @@ soup_cookie_jar_get_cookies (SoupCookieJar *jar, SoupURI *uri,
         */
        cookies = NULL;
        domain = cur = g_strdup_printf (".%s", uri->host);
-       next = domain + 1;
+       next_domain = domain + 1;
        do {
                new_head = domain_cookies = g_hash_table_lookup (priv->domains, cur);
                while (domain_cookies) {
@@ -285,9 +285,9 @@ soup_cookie_jar_get_cookies (SoupCookieJar *jar, SoupURI *uri,
 
                        domain_cookies = next;
                }
-               cur = next;
+               cur = next_domain;
                if (cur)
-                       next = strchr (cur + 1, '.');
+                       next_domain = strchr (cur + 1, '.');
        } while (cur);
        g_free (domain);
 
index fba51c0..4ee5a86 100644 (file)
@@ -723,7 +723,6 @@ soup_message_headers_get_ranges (SoupMessageHeaders  *hdrs,
        const char *range = soup_message_headers_get (hdrs, "Range");
        GSList *range_list, *r;
        GArray *array;
-       SoupRange cur;
        char *spec, *end;
        int i;
 
@@ -744,6 +743,8 @@ soup_message_headers_get_ranges (SoupMessageHeaders  *hdrs,
 
        array = g_array_new (FALSE, FALSE, sizeof (SoupRange));
        for (r = range_list; r; r = r->next) {
+               SoupRange cur;
+
                spec = r->data;
                if (*spec == '-') {
                        cur.start = g_ascii_strtoll (spec, &end, 10) + total_length;
index b7ae814..74792f1 100644 (file)
@@ -22,8 +22,8 @@
 #include "test-utils.h"
 
 static struct {
-       char *title, *name;
-       char *result;
+       const char *title, *name;
+       const char *result;
 } tests[] = {
        /* Both fields must be filled in */
        { NULL, "Name", "" },
index d13b21d..a489b06 100644 (file)
@@ -36,7 +36,7 @@ static SoupURI *base_uri;
 static GHashTable *fetched_urls;
 
 static GPtrArray *
-find_hrefs (SoupURI *base, const char *body, int length)
+find_hrefs (SoupURI *doc_base, const char *body, int length)
 {
        GPtrArray *hrefs = g_ptr_array_new ();
        char *buf = g_strndup (body, length);
@@ -65,19 +65,19 @@ find_hrefs (SoupURI *base, const char *body, int length)
                if (frag)
                        *frag = '\0';
 
-               uri = soup_uri_new_with_base (base, href);
+               uri = soup_uri_new_with_base (doc_base, href);
                g_free (href);
 
                if (!uri)
                        continue;
-               if (base->scheme != uri->scheme ||
-                   base->port != uri->port ||
-                   g_ascii_strcasecmp (base->host, uri->host) != 0) {
+               if (doc_base->scheme != uri->scheme ||
+                   doc_base->port != uri->port ||
+                   g_ascii_strcasecmp (doc_base->host, uri->host) != 0) {
                        soup_uri_free (uri);
                        continue;
                }
 
-               if (strncmp (base->path, uri->path, strlen (base->path)) != 0) {
+               if (strncmp (doc_base->path, uri->path, strlen (doc_base->path)) != 0) {
                        soup_uri_free (uri);
                        continue;
                }
@@ -160,7 +160,7 @@ get_url (const char *url)
 
        if (debug) {
                SoupMessageHeadersIter iter;
-               const char *name, *value;
+               const char *hname, *value;
                char *path = soup_uri_to_string (soup_message_get_uri (msg), TRUE);
 
                printf ("%s %s HTTP/1.%d\n\n", method, path,
@@ -170,8 +170,8 @@ get_url (const char *url)
                        msg->status_code, msg->reason_phrase);
 
                soup_message_headers_iter_init (&iter, msg->response_headers);
-               while (soup_message_headers_iter_next (&iter, &name, &value))
-                       printf ("%s: %s\r\n", name, value);
+               while (soup_message_headers_iter_next (&iter, &hname, &value))
+                       printf ("%s: %s\r\n", hname, value);
                printf ("\n");
        } else
                printf ("%s: %d %s\n", name, msg->status_code, msg->reason_phrase);
index 3c7425a..671ff86 100644 (file)
@@ -10,7 +10,7 @@
 #include "test-utils.h"
 
 typedef struct {
-       char *name, *value;
+       const char *name, *value;
 } Header;
 
 static struct RequestTest {
@@ -549,9 +549,9 @@ static struct ResponseTest {
 static const int num_resptests = G_N_ELEMENTS (resptests);
 
 static struct QValueTest {
-       char *header_value;
-       char *acceptable[7];
-       char *unacceptable[2];
+       const char *header_value;
+       const char *acceptable[7];
+       const char *unacceptable[2];
 } qvaluetests[] = {
        { "text/plain; q=0.5, text/html,\t  text/x-dvi; q=0.8, text/x-c",
          { "text/html", "text/x-c", "text/x-dvi", "text/plain", NULL },
index d33f953..a67bd66 100644 (file)
@@ -118,7 +118,7 @@ do_single_range (SoupSession *session, SoupMessage *msg,
 }
 
 static void
-request_single_range (SoupSession *session, char *uri,
+request_single_range (SoupSession *session, const char *uri,
                      int start, int end)
 {
        SoupMessage *msg;
@@ -188,7 +188,7 @@ do_multi_range (SoupSession *session, SoupMessage *msg,
 }
 
 static void
-request_double_range (SoupSession *session, char *uri,
+request_double_range (SoupSession *session, const char *uri,
                      int first_start, int first_end,
                      int second_start, int second_end,
                      int expected_return_ranges)
@@ -212,7 +212,7 @@ request_double_range (SoupSession *session, char *uri,
 }
 
 static void
-request_triple_range (SoupSession *session, char *uri,
+request_triple_range (SoupSession *session, const char *uri,
                      int first_start, int first_end,
                      int second_start, int second_end,
                      int third_start, int third_end,
@@ -239,7 +239,7 @@ request_triple_range (SoupSession *session, char *uri,
 }
 
 static void
-do_range_test (SoupSession *session, char *uri, gboolean expect_coalesce)
+do_range_test (SoupSession *session, const char *uri, gboolean expect_coalesce)
 {
        int twelfths = full_response->length / 12;
 
index c5e2918..bc48a55 100644 (file)
@@ -148,9 +148,9 @@ debug_printf (int level, const char *format, ...)
 #ifdef HAVE_APACHE
 
 static gboolean
-apache_cmd (char *cmd)
+apache_cmd (const char *cmd)
 {
-       char *argv[8];
+       const char *argv[8];
        char *cwd, *conf;
        int status;
        gboolean ok;
@@ -167,7 +167,7 @@ apache_cmd (char *cmd)
        argv[6] = cmd;
        argv[7] = NULL;
 
-       ok = g_spawn_sync (cwd, argv, NULL, 0, NULL, NULL,
+       ok = g_spawn_sync (cwd, (char **)argv, NULL, 0, NULL, NULL,
                           NULL, NULL, &status, NULL);
        if (ok)
                ok = (status == 0);