+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
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
{
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);
*/
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) {
domain_cookies = next;
}
- cur = next;
+ cur = next_domain;
if (cur)
- next = strchr (cur + 1, '.');
+ next_domain = strchr (cur + 1, '.');
} while (cur);
g_free (domain);
const char *range = soup_message_headers_get (hdrs, "Range");
GSList *range_list, *r;
GArray *array;
- SoupRange cur;
char *spec, *end;
int i;
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;
#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", "" },
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);
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;
}
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,
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);
#include "test-utils.h"
typedef struct {
- char *name, *value;
+ const char *name, *value;
} Header;
static struct RequestTest {
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 },
}
static void
-request_single_range (SoupSession *session, char *uri,
+request_single_range (SoupSession *session, const char *uri,
int start, int end)
{
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)
}
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,
}
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;
#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;
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);