From 44e93e6343f9fe1deb9ad4852683fe5ca8e9a01b Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 4 Dec 2008 18:18:56 +0000 Subject: [PATCH] Fix some cparser warnings. --- actions.c | 14 +++++++++----- cgi.c | 16 ++++++++++------ cgiedit.c | 12 ++++++++---- errlog.c | 11 +++++++---- gateway.c | 10 ++++++---- miscutil.c | 11 +++++++---- 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/actions.c b/actions.c index a66c4645..967a9740 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.53 2008/05/26 16:04:04 fabiankeil Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.54 2008/09/20 10:04:33 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -33,6 +33,10 @@ const char actions_rcs[] = "$Id: actions.c,v 1.53 2008/05/26 16:04:04 fabiankeil * * Revisions : * $Log: actions.c,v $ + * Revision 1.54 2008/09/20 10:04:33 fabiankeil + * Remove hide-forwarded-for-headers action which has + * been obsoleted by change-x-forwarded-for{block}. + * * Revision 1.53 2008/05/26 16:04:04 fabiankeil * s@memorey@memory@ * @@ -683,7 +687,7 @@ static int action_used_to_be_valid(const char *action) "vanilla-wafer", "wafer" }; - int i; + unsigned int i; for (i = 0; i < SZ(formerly_valid_actions); i++) { @@ -870,12 +874,12 @@ jb_err get_actions(char *line, /* Found it */ merge_actions(cur_action, alias->action); } - else if ((2 < strlen(option)) && action_used_to_be_valid(option+1)) + else if (((size_t)2 < strlen(option)) && action_used_to_be_valid(option+1)) { log_error(LOG_LEVEL_ERROR, "Action '%s' is no longer valid " "in this Privoxy release. Ignored.", option+1); } - else if ((2 < strlen(option)) && 0 == strcmpic(option+1, "hide-forwarded-for-headers")) + else if (((size_t)2 < strlen(option)) && 0 == strcmpic(option+1, "hide-forwarded-for-headers")) { log_error(LOG_LEVEL_FATAL, "The action 'hide-forwarded-for-headers' " "is no longer valid in this Privoxy release. " @@ -1353,7 +1357,7 @@ static int load_one_actions_file(struct client_state *csp, int fileid) size_t len = strlen(buf); char * start = buf + 2; char * end = buf + len - 1; - if ((len < 5) || (*end-- != '}') || (*end-- != '}')) + if ((len < (size_t)5) || (*end-- != '}') || (*end-- != '}')) { /* too short */ fclose(fp); diff --git a/cgi.c b/cgi.c index a1b71943..ef98085e 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.112 2008/08/31 16:08:12 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.113 2008/09/04 08:13:58 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,10 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.112 2008/08/31 16:08:12 fabiankeil Exp $" * * Revisions : * $Log: cgi.c,v $ + * Revision 1.113 2008/09/04 08:13:58 fabiankeil + * Prepare for critical sections on Windows by adding a + * layer of indirection before the pthread mutex functions. + * * Revision 1.112 2008/08/31 16:08:12 fabiankeil * "View the request headers" isn't more equal than the other * menu items and thus doesn't need a trailing dot either. @@ -1995,7 +1999,7 @@ void get_http_time(int time_offset, char *buf, size_t buffer_size) #endif assert(buf); - assert(buffer_size > 29); + assert(buffer_size > (size_t)29); time(¤t_time); @@ -2054,7 +2058,7 @@ static void get_locale_time(char *buf, size_t buffer_size) #endif assert(buf); - assert(buffer_size > 29); + assert(buffer_size > (size_t)29); time(¤t_time); @@ -2765,7 +2769,7 @@ jb_err map_block_killer(struct map *exports, const char *name) assert(exports); assert(name); - assert(strlen(name) < 490); + assert(strlen(name) < (size_t)490); snprintf(buf, sizeof(buf), "if-%s-start.*if-%s-end", name, name); return map(exports, buf, 1, "", 1); @@ -2795,7 +2799,7 @@ jb_err map_block_keep(struct map *exports, const char *name) assert(exports); assert(name); - assert(strlen(name) < 490); + assert(strlen(name) < (size_t)490); snprintf(buf, sizeof(buf), "if-%s-start", name); err = map(exports, buf, 1, "", 1); @@ -2842,7 +2846,7 @@ jb_err map_conditional(struct map *exports, const char *name, int choose_first) assert(exports); assert(name); - assert(strlen(name) < 480); + assert(strlen(name) < (size_t)480); snprintf(buf, sizeof(buf), (choose_first ? "else-not-%s@.*@endif-%s" diff --git a/cgiedit.c b/cgiedit.c index 6d742b7c..0f041699 100644 --- a/cgiedit.c +++ b/cgiedit.c @@ -1,4 +1,4 @@ -const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.61 2008/03/24 18:12:52 fabiankeil Exp $"; +const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.62 2008/08/31 15:59:02 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $ @@ -42,6 +42,10 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.61 2008/03/24 18:12:52 fabiankeil * * Revisions : * $Log: cgiedit.c,v $ + * Revision 1.62 2008/08/31 15:59:02 fabiankeil + * There's no reason to let remote toggling support depend + * on FEATURE_CGI_EDIT_ACTIONS, so make sure it doesn't. + * * Revision 1.61 2008/03/24 18:12:52 fabiankeil * Use sizeof() more often. * @@ -892,7 +896,7 @@ jb_err cgi_edit_actions_url_form(struct client_state *csp, if ( (cur_line == NULL) || (line_number != patternid) - || (patternid < 1) + || (patternid < 1U) || (cur_line->type != FILE_LINE_URL)) { /* Invalid "patternid" parameter */ @@ -1052,7 +1056,7 @@ jb_err cgi_edit_actions_remove_url_form(struct client_state *csp, if ( (cur_line == NULL) || (line_number != patternid) - || (patternid < 1) + || (patternid < 1U) || (cur_line->type != FILE_LINE_URL)) { /* Invalid "patternid" parameter */ @@ -1712,7 +1716,7 @@ jb_err edit_parse_actions_file(struct editable_file * file) text++; len--; } - while ( (len > 0) + while ( (len > (size_t)0) && ( (text[len - 1] == ' ') || (text[len - 1] == '\t') ) ) { diff --git a/errlog.c b/errlog.c index 71920c7f..c69b8d71 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.81 2008/11/23 15:59:27 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.82 2008/11/23 16:06:58 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,9 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.81 2008/11/23 15:59:27 fabiankeil E * * Revisions : * $Log: errlog.c,v $ + * Revision 1.82 2008/11/23 16:06:58 fabiankeil + * Update a log message I missed in 1.80. + * * Revision 1.81 2008/11/23 15:59:27 fabiankeil * - Update copyright range. * - Remove stray line breaks in a log message @@ -803,7 +806,7 @@ static inline size_t get_log_timestamp(char *buffer, size_t buffer_size) #endif length = strftime(buffer, buffer_size, "%b %d %H:%M:%S", &tm_now); - if (length > 0) + if (length > (size_t)0) { msecs_length = snprintf(buffer+length, buffer_size - length, ".%.3ld", msecs); } @@ -874,7 +877,7 @@ static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size) length = strftime(buffer, buffer_size, "%d/%b/%Y:%H:%M:%S ", tm_now); - if (length > 0) + if (length > (size_t)0) { tz_length = snprintf(buffer+length, buffer_size-length, "%+03d%02d", mins / 60, abs(mins) % 60); @@ -1153,7 +1156,7 @@ void log_error(int loglevel, const char *fmt, ...) format_string = "[counted string lenght < 0]"; } } - else if (ival >= sizeof(tempbuf)) + else if ((size_t)ival >= sizeof(tempbuf)) { /* * String is too long, copy as much as possible. diff --git a/gateway.c b/gateway.c index 2d3a4913..adcb11c9 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.43 2008/11/13 09:15:51 fabiankeil Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.44 2008/11/22 11:54:04 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -34,6 +34,9 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.43 2008/11/13 09:15:51 fabiankeil * * Revisions : * $Log: gateway.c,v $ + * Revision 1.44 2008/11/22 11:54:04 fabiankeil + * Move log message around to include the socket number. + * * Revision 1.43 2008/11/13 09:15:51 fabiankeil * Make keep_alive_timeout static. * @@ -1106,7 +1109,6 @@ static jb_socket socks4_connect(const struct forward_spec * fwd, { case SOCKS_REQUEST_GRANTED: return(sfd); - break; case SOCKS_REQUEST_REJECT: errstr = "SOCKS request rejected or failed."; errno = EINVAL; @@ -1229,7 +1231,7 @@ static jb_socket socks5_connect(const struct forward_spec *fwd, } hostlen = strlen(target_host); - if (hostlen > 255) + if (hostlen > (size_t)255) { errstr = "target host name is longer than 255 characters"; err = 1; @@ -1317,7 +1319,7 @@ static jb_socket socks5_connect(const struct forward_spec *fwd, cbuf[client_pos++] = '\x00'; /* Reserved, must be 0x00 */ cbuf[client_pos++] = '\x03'; /* Address is domain name */ cbuf[client_pos++] = (char)(hostlen & 0xffu); - assert(sizeof(cbuf) - client_pos > 255); + assert(sizeof(cbuf) - client_pos > (size_t)255); /* Using strncpy because we really want the nul byte padding. */ strncpy(cbuf + client_pos, target_host, sizeof(cbuf) - client_pos); client_pos += (hostlen & 0xffu); diff --git a/miscutil.c b/miscutil.c index 5ddf9808..99dd5707 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,4 +1,4 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.60 2008/09/07 12:35:05 fabiankeil Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 1.61 2008/10/18 11:09:23 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $ @@ -44,6 +44,9 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.60 2008/09/07 12:35:05 fabianke * * Revisions : * $Log: miscutil.c,v $ + * Revision 1.61 2008/10/18 11:09:23 fabiankeil + * Improve seed used by pick_from_range() on mingw32. + * * Revision 1.60 2008/09/07 12:35:05 fabiankeil * Add mutex lock support for _WIN32. * @@ -556,7 +559,7 @@ int strcmpic(const char *s1, const char *s2) *********************************************************************/ int strncmpic(const char *s1, const char *s2, size_t n) { - if (n <= 0) return(0); + if (n <= (size_t)0) return(0); if (!s1) s1 = ""; if (!s2) s2 = ""; @@ -567,7 +570,7 @@ int strncmpic(const char *s1, const char *s2, size_t n) break; } - if (--n <= 0) break; + if (--n <= (size_t)0) break; s1++, s2++; } @@ -761,7 +764,7 @@ jb_err string_join(char **target_string, char *text_to_append) err = string_append(target_string, text_to_append); - free(text_to_append); + freez(text_to_append); return err; } -- 2.39.2