From: jongfoster Date: Wed, 13 Mar 2002 00:29:59 +0000 (+0000) Subject: Killing warnings X-Git-Tag: v_2_9_12~46 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=17ef7337d1a41e4733c1ec662c3b1191d0c76a8a Killing warnings --- diff --git a/cgi.c b/cgi.c index c5810786..e1960974 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.47 2002/03/08 16:41:33 oes Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.48 2002/03/08 17:47:07 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -38,6 +38,9 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.47 2002/03/08 16:41:33 oes Exp $"; * * Revisions : * $Log: cgi.c,v $ + * Revision 1.48 2002/03/08 17:47:07 jongfoster + * Adding comments + * * Revision 1.47 2002/03/08 16:41:33 oes * Added GIF images again * @@ -660,7 +663,8 @@ static struct http_response *dispatch_known_cgi(struct client_state * csp, csp->ip_addr_str, csp->http->cmd); /* Find and start the right CGI function*/ - for (d = cgi_dispatchers; FOREVER; d++) + d = cgi_dispatchers; + for (;;) { if ((d->name == NULL) || (strcmp(path_copy, d->name) == 0)) { @@ -683,6 +687,7 @@ static struct http_response *dispatch_known_cgi(struct client_state * csp, return cgi_error_memory(); } } + d++; } } diff --git a/deanimate.c b/deanimate.c index 1dbc6651..6d37759f 100644 --- a/deanimate.c +++ b/deanimate.c @@ -1,4 +1,4 @@ -const char deanimate_rcs[] = "$Id: deanimate.c,v 1.7 2002/03/08 17:46:04 jongfoster Exp $"; +const char deanimate_rcs[] = "$Id: deanimate.c,v 1.8 2002/03/09 19:42:47 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/deanimate.c,v $ @@ -37,6 +37,9 @@ const char deanimate_rcs[] = "$Id: deanimate.c,v 1.7 2002/03/08 17:46:04 jongfos * * Revisions : * $Log: deanimate.c,v $ + * Revision 1.8 2002/03/09 19:42:47 jongfoster + * Fixing more warnings + * * Revision 1.7 2002/03/08 17:46:04 jongfoster * Fixing int/size_t warnings * @@ -242,7 +245,7 @@ int gif_skip_data_block(struct binbuffer *buf) * by a one-byte length field, with the last chunk having * zero length. */ - while((c = buf_getbyte(buf, 0))) + while((c = buf_getbyte(buf, 0)) != '\0') { if ((buf->offset += c + 1) >= buf->size - 1) { @@ -300,7 +303,7 @@ int gif_extract_image(struct binbuffer *src, struct binbuffer *dst) /* * Copy the image chunk by chunk. */ - while((c = buf_getbyte(src, 0))) + while((c = buf_getbyte(src, 0)) != '\0') { if (buf_copy(src, dst, 1 + (size_t) c)) return 1; } diff --git a/encode.c b/encode.c index 01457a7a..07263d83 100644 --- a/encode.c +++ b/encode.c @@ -1,4 +1,4 @@ -const char encode_rcs[] = "$Id: encode.c,v 1.4 2002/01/22 23:28:07 jongfoster Exp $"; +const char encode_rcs[] = "$Id: encode.c,v 1.5 2002/03/07 03:46:53 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/encode.c,v $ @@ -33,6 +33,9 @@ const char encode_rcs[] = "$Id: encode.c,v 1.4 2002/01/22 23:28:07 jongfoster Ex * * Revisions : * $Log: encode.c,v $ + * Revision 1.5 2002/03/07 03:46:53 oes + * Fixed compiler warnings etc + * * Revision 1.4 2002/01/22 23:28:07 jongfoster * Adding convenience function html_encode_and_free_original() * Making all functions accept NULL paramaters - in this case, they @@ -442,7 +445,7 @@ char *url_decode(const char * s) break; case '%': - if ((*q = xtoi(s + 1))) + if ((*q = xtoi(s + 1)) != '\0') { s += 3; q++; diff --git a/errlog.c b/errlog.c index f91461ea..409723f8 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.31 2002/03/06 23:02:57 jongfoster Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.32 2002/03/07 03:46:17 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,9 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.31 2002/03/06 23:02:57 jongfoster E * * Revisions : * $Log: errlog.c,v $ + * Revision 1.32 2002/03/07 03:46:17 oes + * Fixed compiler warnings + * * Revision 1.31 2002/03/06 23:02:57 jongfoster * Removing tabs * @@ -315,7 +318,7 @@ void init_error_log(const char *prog_name, const char *logfname, int debuglevel) /* set the designated log file */ if( logfname ) { - if( !(fp = fopen(logfname, "a")) ) + if( NULL == (fp = fopen(logfname, "a")) ) { log_error(LOG_LEVEL_FATAL, "init_error_log(): can't open logfile: %s", logfname); } diff --git a/gateway.c b/gateway.c index 7d67ff0d..5c371ee0 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.11 2002/03/08 17:46:04 jongfoster Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.12 2002/03/09 20:03:52 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -34,6 +34,30 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.11 2002/03/08 17:46:04 jongfoster * * Revisions : * $Log: gateway.c,v $ + * Revision 1.12 2002/03/09 20:03:52 jongfoster + * - Making various functions return int rather than size_t. + * (Undoing a recent change). Since size_t is unsigned on + * Windows, functions like read_socket that return -1 on + * error cannot return a size_t. + * + * THIS WAS A MAJOR BUG - it caused frequent, unpredictable + * crashes, and also frequently caused JB to jump to 100% + * CPU and stay there. (Because it thought it had just + * read ((unsigned)-1) == 4Gb of data...) + * + * - The signature of write_socket has changed, it now simply + * returns success=0/failure=nonzero. + * + * - Trying to get rid of a few warnings --with-debug on + * Windows, I've introduced a new type "jb_socket". This is + * used for the socket file descriptors. On Windows, this + * is SOCKET (a typedef for unsigned). Everywhere else, it's + * an int. The error value can't be -1 any more, so it's + * now JB_INVALID_SOCKET (which is -1 on UNIX, and in + * Windows it maps to the #define INVALID_SOCKET.) + * + * - The signature of bind_port has changed. + * * Revision 1.11 2002/03/08 17:46:04 jongfoster * Fixing int/size_t warnings * @@ -306,7 +330,7 @@ static jb_socket socks4_connect(const struct forward_spec * fwd, return(JB_INVALID_SOCKET); } - if (write_socket(sfd, (char *)c, (int)csiz)) + if (write_socket(sfd, (char *)c, csiz)) { log_error(LOG_LEVEL_CONNECT, "SOCKS4 negotiation write failed..."); close_socket(sfd); diff --git a/jbsockets.c b/jbsockets.c index 86f1fde5..a2e1fad0 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,4 +1,4 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.25 2002/03/09 20:03:52 jongfoster Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.26 2002/03/11 22:07:02 david__schmidt Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ @@ -35,6 +35,12 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.25 2002/03/09 20:03:52 jongfo * * Revisions : * $Log: jbsockets.c,v $ + * Revision 1.26 2002/03/11 22:07:02 david__schmidt + * OS/2 port maintenance: + * - Fixed EMX build - it had decayed a little + * - Fixed inexplicable crash during FD_ZERO - must be due to a bad macro. + * substituted a memset for now. + * * Revision 1.25 2002/03/09 20:03:52 jongfoster * - Making various functions return int rather than size_t. * (Undoing a recent change). Since size_t is unsigned on @@ -360,7 +366,7 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp) * nonzero on error. * *********************************************************************/ -int write_socket(jb_socket fd, const char *buf, int len) +int write_socket(jb_socket fd, const char *buf, size_t len) { if (len == 0) { @@ -374,7 +380,9 @@ int write_socket(jb_socket fd, const char *buf, int len) log_error(LOG_LEVEL_LOG, "%N", len, buf); -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) +#if defined(_WIN32) + return (send(fd, buf, (int)len, 0) != (int)len); +#elif defined(__BEOS__) || defined(AMIGA) return (send(fd, buf, len, 0) != len); #elif defined(__OS2__) /* @@ -436,10 +444,12 @@ int read_socket(jb_socket fd, char *buf, int len) return(0); } -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) +#if defined(_WIN32) return(recv(fd, buf, len, 0)); +#elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) + return(recv(fd, buf, (size_t)len, 0)); #else - return(read(fd, buf, len)); + return(read(fd, buf, (size_t)len)); #endif } @@ -600,7 +610,12 @@ int accept_connection(struct client_state * csp, jb_socket fd) struct sockaddr_in client, server; struct hostent *host = NULL; jb_socket afd; +#ifdef _WIN32 + /* Microsoft wierdness - fix a warning. */ + int c_length, s_length; +#else size_t c_length, s_length; +#endif #if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS) struct hostent result; #if defined(HAVE_GETHOSTBYADDR_R_5_ARGS) diff --git a/jbsockets.h b/jbsockets.h index 08f0ddec..59df0ea3 100644 --- a/jbsockets.h +++ b/jbsockets.h @@ -1,6 +1,6 @@ #ifndef JBSOCKETS_H_INCLUDED #define JBSOCKETS_H_INCLUDED -#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.4 2002/03/07 03:51:36 oes Exp $" +#define JBSOCKETS_H_VERSION "$Id: jbsockets.h,v 1.5 2002/03/09 20:03:52 jongfoster Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.h,v $ @@ -37,6 +37,30 @@ * * Revisions : * $Log: jbsockets.h,v $ + * Revision 1.5 2002/03/09 20:03:52 jongfoster + * - Making various functions return int rather than size_t. + * (Undoing a recent change). Since size_t is unsigned on + * Windows, functions like read_socket that return -1 on + * error cannot return a size_t. + * + * THIS WAS A MAJOR BUG - it caused frequent, unpredictable + * crashes, and also frequently caused JB to jump to 100% + * CPU and stay there. (Because it thought it had just + * read ((unsigned)-1) == 4Gb of data...) + * + * - The signature of write_socket has changed, it now simply + * returns success=0/failure=nonzero. + * + * - Trying to get rid of a few warnings --with-debug on + * Windows, I've introduced a new type "jb_socket". This is + * used for the socket file descriptors. On Windows, this + * is SOCKET (a typedef for unsigned). Everywhere else, it's + * an int. The error value can't be -1 any more, so it's + * now JB_INVALID_SOCKET (which is -1 on UNIX, and in + * Windows it maps to the #define INVALID_SOCKET.) + * + * - The signature of bind_port has changed. + * * Revision 1.4 2002/03/07 03:51:36 oes * - Improved handling of failed DNS lookups * - Fixed compiler warnings etc @@ -64,7 +88,7 @@ extern "C" { struct client_state; extern jb_socket connect_to(const char *host, int portnum, struct client_state *csp); -extern int write_socket(jb_socket fd, const char *buf, int n); +extern int write_socket(jb_socket fd, const char *buf, size_t n); extern int read_socket(jb_socket fd, char *buf, int n); extern void close_socket(jb_socket fd); diff --git a/jcc.c b/jcc.c index 0997ef86..bdb26a32 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.80 2002/03/11 22:07:05 david__schmidt Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.81 2002/03/12 01:42:50 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.80 2002/03/11 22:07:05 david__schmidt Exp * * Revisions : * $Log: jcc.c,v $ + * Revision 1.81 2002/03/12 01:42:50 oes + * Introduced modular filters + * * Revision 1.80 2002/03/11 22:07:05 david__schmidt * OS/2 port maintenance: * - Fixed EMX build - it had decayed a little @@ -741,7 +744,7 @@ static void chat(struct client_state *csp) * could get blocked here if a client connected, then didn't say anything! */ - while (FOREVER) + for (;;) { len = read_socket(csp->cfd, buf, sizeof(buf)); @@ -956,9 +959,9 @@ static void chat(struct client_state *csp) /* grab the rest of the client's headers */ - while (FOREVER) + for (;;) { - if ( ( p = get_header(csp) ) && ( *p == '\0' ) ) + if ( ( ( p = get_header(csp) ) != NULL) && ( *p == '\0' ) ) { len = read_socket(csp->cfd, buf, sizeof(buf)); if (len <= 0) @@ -1146,7 +1149,7 @@ static void chat(struct client_state *csp) server_body = 0; - while (FOREVER) + for (;;) { #ifdef __OS2__ /* @@ -1160,7 +1163,7 @@ static void chat(struct client_state *csp) FD_SET(csp->cfd, &rfds); FD_SET(csp->sfd, &rfds); - n = select(maxfd+1, &rfds, NULL, NULL, NULL); + n = select((int)maxfd+1, &rfds, NULL, NULL, NULL); if (n < 0) { @@ -1181,7 +1184,7 @@ static void chat(struct client_state *csp) break; /* "game over, man" */ } - if (write_socket(csp->sfd, buf, len)) + if (write_socket(csp->sfd, buf, (size_t)len)) { log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host); return; @@ -1332,6 +1335,8 @@ static void chat(struct client_state *csp) */ if (((size_t)(csp->iob->eod - csp->iob->buf)) + (size_t)BUFFER_SIZE > csp->config->buffer_limit) { + size_t hdrlen; + log_error(LOG_LEVEL_ERROR, "Buffer size limit reached! Flushing and stepping back."); hdr = sed(server_patterns, add_server_headers, csp); @@ -1341,11 +1346,11 @@ static void chat(struct client_state *csp) log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header"); } - len = strlen(hdr); - byte_count += len; + hdrlen = strlen(hdr); + byte_count += hdrlen; - if (write_socket(csp->cfd, hdr, len) - || (len = flush_socket(csp->cfd, csp) < 0)) + if (write_socket(csp->cfd, hdr, hdrlen) + || ((len = flush_socket(csp->cfd, csp)) < 0)) { log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E"); @@ -1363,7 +1368,7 @@ static void chat(struct client_state *csp) } else { - if (write_socket(csp->cfd, buf, len)) + if (write_socket(csp->cfd, buf, (size_t)len)) { log_error(LOG_LEVEL_ERROR, "write to client failed: %E"); return; @@ -1384,7 +1389,7 @@ static void chat(struct client_state *csp) /* get header lines from the iob */ - while ((p = get_header(csp))) + while ((p = get_header(csp)) != NULL) { if (*p == '\0') { @@ -1480,10 +1485,8 @@ static void chat(struct client_state *csp) * may be in the buffer) */ - len = strlen(hdr); - - if (write_socket(csp->cfd, hdr, len) - || (len = flush_socket(csp->cfd, csp) < 0)) + if (write_socket(csp->cfd, hdr, strlen(hdr)) + || ((len = flush_socket(csp->cfd, csp)) < 0)) { log_error(LOG_LEVEL_CONNECT, "write header to client failed: %E"); @@ -1971,7 +1974,7 @@ static void listen_loop(void) bfd = bind_port_helper(config); - while (FOREVER) + for (;;) { #if !defined(FEATURE_PTHREAD) && !defined(_WIN32) && !defined(__BEOS__) && !defined(AMIGA) && !defined(__OS2__) while (waitpid(-1, NULL, WNOHANG) > 0) @@ -2099,7 +2102,7 @@ static void listen_loop(void) #if defined(_WIN32) && !defined(_CYGWIN) && !defined(SELECTED_ONE_OPTION) #define SELECTED_ONE_OPTION child_id = _beginthread( - (void*)serve, + (void (*)(void *))serve, 64 * 1024, csp); #endif diff --git a/loadcfg.c b/loadcfg.c index 03729bf5..98814659 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.34 2002/03/06 23:14:35 jongfoster Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.35 2002/03/07 03:52:44 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,9 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.34 2002/03/06 23:14:35 jongfoster * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.35 2002/03/07 03:52:44 oes + * Set logging to tty for --no-daemon mode + * * Revision 1.34 2002/03/06 23:14:35 jongfoster * Trivial cosmetic changes to make function comments easier to find. * @@ -774,7 +777,7 @@ struct configuration_spec * load_config(void) { cur_fwd->forward_host = strdup(p); - if ((p = strchr(cur_fwd->forward_host, ':'))) + if (NULL != (p = strchr(cur_fwd->forward_host, ':'))) { *p++ = '\0'; cur_fwd->forward_port = atoi(p); @@ -837,7 +840,7 @@ struct configuration_spec * load_config(void) { cur_fwd->gateway_host = strdup(p); - if ((p = strchr(cur_fwd->gateway_host, ':'))) + if (NULL != (p = strchr(cur_fwd->gateway_host, ':'))) { *p++ = '\0'; cur_fwd->gateway_port = atoi(p); @@ -855,7 +858,7 @@ struct configuration_spec * load_config(void) { cur_fwd->forward_host = strdup(p); - if ((p = strchr(cur_fwd->forward_host, ':'))) + if (NULL != (p = strchr(cur_fwd->forward_host, ':'))) { *p++ = '\0'; cur_fwd->forward_port = atoi(p); @@ -916,7 +919,7 @@ struct configuration_spec * load_config(void) cur_fwd->gateway_host = strdup(p); - if ((p = strchr(cur_fwd->gateway_host, ':'))) + if (NULL != (p = strchr(cur_fwd->gateway_host, ':'))) { *p++ = '\0'; cur_fwd->gateway_port = atoi(p); @@ -933,7 +936,7 @@ struct configuration_spec * load_config(void) { cur_fwd->forward_host = strdup(p); - if ((p = strchr(cur_fwd->forward_host, ':'))) + if (NULL != (p = strchr(cur_fwd->forward_host, ':'))) { *p++ = '\0'; cur_fwd->forward_port = atoi(p); @@ -1310,7 +1313,7 @@ struct configuration_spec * load_config(void) if ( NULL != config->haddr ) { - if ((p = strchr(config->haddr, ':'))) + if (NULL != (p = strchr(config->haddr, ':'))) { *p++ = '\0'; if (*p) diff --git a/loaders.c b/loaders.c index 70361585..75f508f6 100644 --- a/loaders.c +++ b/loaders.c @@ -1,4 +1,4 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.40 2002/03/08 17:46:04 jongfoster Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.41 2002/03/12 01:42:50 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ @@ -35,6 +35,9 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.40 2002/03/08 17:46:04 jongfoster * * Revisions : * $Log: loaders.c,v $ + * Revision 1.41 2002/03/12 01:42:50 oes + * Introduced modular filters + * * Revision 1.40 2002/03/08 17:46:04 jongfoster * Fixing int/size_t warnings * @@ -310,7 +313,7 @@ void sweep(void) fl->active = 0; } - for (csp = clients; csp && (ncsp = csp->next) ; csp = csp->next) + for (csp = clients; csp && (NULL != (ncsp = csp->next)) ; csp = csp->next) { if (ncsp->flags & CSP_FLAG_ACTIVE) { @@ -376,13 +379,13 @@ void sweep(void) freez(ncsp); /* are there any more in sequence after it? */ - if( !(ncsp = csp->next) ) + if( (ncsp = csp->next) == NULL) break; } } } - for (fl = files; fl && (nfl = fl->next) ; fl = fl->next) + for (fl = files; fl && ((nfl = fl->next) != NULL) ; fl = fl->next) { if ( ( 0 == nfl->active ) && ( NULL != nfl->unloader ) ) { @@ -519,7 +522,7 @@ jb_err simple_read_line(FILE *fp, char **dest, int *newline) #define CHAR_CR '\r' /* ASCII 13 */ #define CHAR_LF '\n' /* ASCII 10 */ - while (FOREVER) + for (;;) { ch = fgetc(fp); if (ch == EOF) @@ -1018,7 +1021,7 @@ int load_trustfile(struct client_state *csp) reject = 0; p = buf; q = p+1; - while ((*p++ = *q++)) + while ((*p++ = *q++) != '\0') { /* nop */ } diff --git a/parsers.c b/parsers.c index 8824d2df..bec42ec2 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.49 2002/03/09 20:03:52 jongfoster Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.50 2002/03/12 01:45:35 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -40,6 +40,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.49 2002/03/09 20:03:52 jongfoster * * Revisions : * $Log: parsers.c,v $ + * Revision 1.50 2002/03/12 01:45:35 oes + * More verbose logging + * * Revision 1.49 2002/03/09 20:03:52 jongfoster * - Making various functions return int rather than size_t. * (Undoing a recent change). Since size_t is unsigned on @@ -479,7 +482,7 @@ int flush_socket(jb_socket fd, struct client_state *csp) return(0); } - if (write_socket(fd, iob->cur, len)) + if (write_socket(fd, iob->cur, (size_t)len)) { return(-1); } @@ -500,10 +503,10 @@ int flush_socket(jb_socket fd, struct client_state *csp) * 2 : buf = holds the content to be added to the page * 3 : n = number of bytes to be added * - * Returns : Number of bytes in the content buffer. + * Returns : None * *********************************************************************/ -size_t add_to_iob(struct client_state *csp, char *buf, size_t n) +void add_to_iob(struct client_state *csp, char *buf, int n) { struct iob *iob = csp->iob; size_t have, need; @@ -513,7 +516,7 @@ size_t add_to_iob(struct client_state *csp, char *buf, size_t n) if (n <= 0) { - return(have); + return; } need = have + n; @@ -543,7 +546,7 @@ size_t add_to_iob(struct client_state *csp, char *buf, size_t n) } /* copy the new data into the iob buffer */ - memcpy(p, buf, n); + memcpy(p, buf, (size_t)n); /* point to the end of the data */ p += n; @@ -555,7 +558,7 @@ size_t add_to_iob(struct client_state *csp, char *buf, size_t n) iob->cur = iob->buf; iob->eod = p; - return(need); + return; } @@ -600,7 +603,7 @@ char *get_header(struct client_state *csp) iob->cur = p+1; - if ((q = strchr(ret, '\r'))) *q = '\0'; + if ((q = strchr(ret, '\r')) != NULL) *q = '\0'; /* is this a blank linke (i.e. the end of the header) ? */ if (*ret == '\0') @@ -1739,7 +1742,7 @@ int strclean(const char *string, const char *substring) int hits = 0, len = strlen(substring); char *pos, *p; - while((pos = strstr(string, substring))) + while((pos = strstr(string, substring)) != NULL) { p = pos + len; do diff --git a/parsers.h b/parsers.h index 1526cb1f..92845760 100644 --- a/parsers.h +++ b/parsers.h @@ -1,6 +1,6 @@ #ifndef PARSERS_H_INCLUDED #define PARSERS_H_INCLUDED -#define PARSERS_H_VERSION "$Id: parsers.h,v 1.21 2002/03/07 03:46:17 oes Exp $" +#define PARSERS_H_VERSION "$Id: parsers.h,v 1.22 2002/03/09 20:03:52 jongfoster Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.h,v $ @@ -43,6 +43,30 @@ * * Revisions : * $Log: parsers.h,v $ + * Revision 1.22 2002/03/09 20:03:52 jongfoster + * - Making various functions return int rather than size_t. + * (Undoing a recent change). Since size_t is unsigned on + * Windows, functions like read_socket that return -1 on + * error cannot return a size_t. + * + * THIS WAS A MAJOR BUG - it caused frequent, unpredictable + * crashes, and also frequently caused JB to jump to 100% + * CPU and stay there. (Because it thought it had just + * read ((unsigned)-1) == 4Gb of data...) + * + * - The signature of write_socket has changed, it now simply + * returns success=0/failure=nonzero. + * + * - Trying to get rid of a few warnings --with-debug on + * Windows, I've introduced a new type "jb_socket". This is + * used for the socket file descriptors. On Windows, this + * is SOCKET (a typedef for unsigned). Everywhere else, it's + * an int. The error value can't be -1 any more, so it's + * now JB_INVALID_SOCKET (which is -1 on UNIX, and in + * Windows it maps to the #define INVALID_SOCKET.) + * + * - The signature of bind_port has changed. + * * Revision 1.21 2002/03/07 03:46:17 oes * Fixed compiler warnings * @@ -146,7 +170,7 @@ extern const add_header_func_ptr add_client_headers[]; extern const add_header_func_ptr add_server_headers[]; extern int flush_socket(jb_socket fd, struct client_state *csp); -extern size_t add_to_iob(struct client_state *csp, char *buf, size_t n); +extern void add_to_iob(struct client_state *csp, char *buf, int n); extern char *get_header(struct client_state *csp); extern char *get_header_value(const struct list *header_list, const char *header_name); extern char *sed(const struct parsers pats[], const add_header_func_ptr more_headers[], struct client_state *csp); diff --git a/urlmatch.c b/urlmatch.c index 28dd245e..4dd64656 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.3 2002/03/03 14:51:11 oes Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.4 2002/03/07 03:46:17 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -33,6 +33,9 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.3 2002/03/03 14:51:11 oes Exp $ * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.4 2002/03/07 03:46:17 oes + * Fixed compiler warnings + * * Revision 1.3 2002/03/03 14:51:11 oes * Fixed CLF logging: Added ocmd member for client's request to struct http_request * @@ -608,7 +611,7 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) return JB_ERR_MEMORY; } - if ((p = strchr(buf, '/'))) + if ((p = strchr(buf, '/')) != NULL) { if (NULL == (url->path = strdup(p))) {