From: William A. Rowe Jr Date: Sun, 20 Jan 2002 20:14:38 +0000 (+0000) Subject: Dispatch 26 compiler emits into oblivion. Vetting is desired, please X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95980ce1c07071db3efbc9569bcd325ce4d8e0f8;p=thirdparty%2Fapache%2Fhttpd.git Dispatch 26 compiler emits into oblivion. Vetting is desired, please post to the list if you participate. They are all blindingly obvious, but extra eyes always help This eliminates all but the regex emits and MSVC's borked misdeclaration of FD_SET. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@92949 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/main/http_config.c b/src/main/http_config.c index 795cbb97254..153997b4156 100644 --- a/src/main/http_config.c +++ b/src/main/http_config.c @@ -1566,7 +1566,9 @@ static void default_listeners(pool *p, server_rec *s) new = ap_pcalloc(p, sizeof(listen_rec)); new->local_addr.sin_family = AF_INET; new->local_addr.sin_addr = ap_bind_address; - new->local_addr.sin_port = htons(s->port ? s->port : DEFAULT_HTTP_PORT); + /* Buck ugly cast to get around terniary op bug in some (MS) compilers */ + new->local_addr.sin_port = htons((unsigned short)(s->port ? s->port + : DEFAULT_HTTP_PORT)); new->fd = -1; new->used = 0; new->next = NULL; diff --git a/src/main/http_protocol.c b/src/main/http_protocol.c index 62a18fe5740..516daa0252d 100644 --- a/src/main/http_protocol.c +++ b/src/main/http_protocol.c @@ -1061,7 +1061,7 @@ static void get_mime_headers(request_rec *r) char *value; char *copy; int len; - unsigned int fields_read = 0; + int fields_read = 0; table *tmp_headers; /* We'll use ap_overlap_tables later to merge these into r->headers_in. */ @@ -1968,7 +1968,8 @@ API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy) } max_body = ap_get_limit_req_body(r); - if (max_body && (r->remaining > max_body)) { + if (max_body && ((unsigned long)r->remaining > max_body) + && (r->remaining >= 0)) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Request content-length of %s is larger than the configured " "limit of %lu", lenp, max_body); @@ -2076,7 +2077,8 @@ API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz) * length requests and nobody cares if it goes over by one buffer. */ max_body = ap_get_limit_req_body(r); - if (max_body && (r->read_length > max_body)) { + if (max_body && ((unsigned long) r->read_length > max_body) + && (r->read_length >= 0)) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Chunked request body is larger than the configured limit of %lu", max_body); diff --git a/src/main/rfc1413.c b/src/main/rfc1413.c index 007b67a0799..6fd6b36ce38 100644 --- a/src/main/rfc1413.c +++ b/src/main/rfc1413.c @@ -161,7 +161,7 @@ static int get_rfc1413(int sock, const struct sockaddr_in *our_sin, ebcdic2ascii(buffer, buffer, buflen); #endif i = 0; - while(i < strlen(buffer)) { + while(i < (int)strlen(buffer)) { int j; j = write(sock, buffer+i, (strlen(buffer+i))); if (j < 0 && errno != EINTR) { diff --git a/src/main/util_uri.c b/src/main/util_uri.c index 19017a6b15b..77c1d1f3cc6 100644 --- a/src/main/util_uri.c +++ b/src/main/util_uri.c @@ -483,7 +483,7 @@ API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, ++s; uptr->port_str = ap_pstrdup(p, s); if (*s != '\0') { - uptr->port = strtol(uptr->port_str, &endstr, 10); + uptr->port = (unsigned short)strtol(uptr->port_str, &endstr, 10); if (*endstr == '\0') { return HTTP_OK; } diff --git a/src/modules/proxy/mod_proxy.c b/src/modules/proxy/mod_proxy.c index d11ccbe3ad8..eb1fcb1bcd8 100644 --- a/src/modules/proxy/mod_proxy.c +++ b/src/modules/proxy/mod_proxy.c @@ -441,7 +441,7 @@ static void * ps->cache.dirlevels_set = 0; ps->cache.dirlength = 1; ps->cache.dirlength_set = 0; - ps->cache.cache_completion = DEFAULT_CACHE_COMPLETION; + ps->cache.cache_completion = (float)DEFAULT_CACHE_COMPLETION; ps->cache.cache_completion_set = 0; return ps; diff --git a/src/modules/proxy/proxy_connect.c b/src/modules/proxy/proxy_connect.c index d10b84300dd..50fae783260 100644 --- a/src/modules/proxy/proxy_connect.c +++ b/src/modules/proxy/proxy_connect.c @@ -174,7 +174,8 @@ int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url, "CONNECT to %s on port %d", host, port); } - server.sin_port = (proxyport ? htons(proxyport) : htons(port)); + /* Nasty cast to work around broken terniary expressions on MSVC */ + server.sin_port = htons((unsigned short)(proxyport ? proxyport : port)); err = ap_proxy_host2addr(proxyhost ? proxyhost : host, &server_hp); if (err != NULL) diff --git a/src/modules/proxy/proxy_ftp.c b/src/modules/proxy/proxy_ftp.c index 036ebc31bb2..7c38f0ae7d7 100644 --- a/src/modules/proxy/proxy_ftp.c +++ b/src/modules/proxy/proxy_ftp.c @@ -547,7 +547,7 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url) memset(&server, 0, sizeof(struct sockaddr_in)); server.sin_family = AF_INET; - server.sin_port = htons(port); + server.sin_port = htons((unsigned short)port); err = ap_proxy_host2addr(host, &server_hp); if (err != NULL) return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err); diff --git a/src/modules/proxy/proxy_http.c b/src/modules/proxy/proxy_http.c index 2d339595f3d..1eb522b634c 100644 --- a/src/modules/proxy/proxy_http.c +++ b/src/modules/proxy/proxy_http.c @@ -219,13 +219,13 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, } if (proxyhost != NULL) { - server.sin_port = htons(proxyport); + server.sin_port = htons((unsigned short)proxyport); err = ap_proxy_host2addr(proxyhost, &server_hp); if (err != NULL) return DECLINED; /* try another */ } else { - server.sin_port = htons(destport); + server.sin_port = htons((unsigned short)destport); err = ap_proxy_host2addr(desthost, &server_hp); if (err != NULL) return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err); diff --git a/src/modules/standard/mod_include.c b/src/modules/standard/mod_include.c index 83dd08f6d72..6e5f979c343 100644 --- a/src/modules/standard/mod_include.c +++ b/src/modules/standard/mod_include.c @@ -455,7 +455,7 @@ static int get_directive(FILE *in, char *dest, size_t len, pool *p) } /* now get directive */ while (1) { - if (d - dest == len) { + if (d == len + dest) { return 1; } *d++ = ap_tolower(c); @@ -552,7 +552,7 @@ static void parse_string(request_rec *r, const char *in, char *out, /* zero-length variable name causes just the $ to be copied */ l = 1; } - l = (l > end_out - next) ? (end_out - next) : l; + l = (l + next > end_out) ? (end_out - next) : l; memcpy(next, expansion, l); next += l; break; diff --git a/src/modules/standard/mod_mime.c b/src/modules/standard/mod_mime.c index c6c254fbdca..f5a4acf208a 100644 --- a/src/modules/standard/mod_mime.c +++ b/src/modules/standard/mod_mime.c @@ -392,7 +392,7 @@ static char *zap_sp(char *s) return (s); } -static int is_token(char c) +static int is_token(int c) { int res; @@ -401,7 +401,7 @@ static int is_token(char c) return res; } -static int is_qtext(char c) +static int is_qtext(int c) { int res; diff --git a/src/modules/standard/mod_mime_magic.c b/src/modules/standard/mod_mime_magic.c index 4fcd7e4e6c1..b6f9bd1ce83 100644 --- a/src/modules/standard/mod_mime_magic.c +++ b/src/modules/standard/mod_mime_magic.c @@ -1812,7 +1812,7 @@ static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s, { long offset = m->offset; - if (offset + sizeof(union VALUETYPE) > nbytes) + if (offset + (long)sizeof(union VALUETYPE) > nbytes) return 0; memcpy(p, s + offset, sizeof(union VALUETYPE)); @@ -1834,7 +1834,7 @@ static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s, break; } - if (offset + sizeof(union VALUETYPE) > nbytes) + if (offset + (long)sizeof(union VALUETYPE) > nbytes) return 0; memcpy(p, s + offset, sizeof(union VALUETYPE)); diff --git a/src/modules/standard/mod_negotiation.c b/src/modules/standard/mod_negotiation.c index 3fad90dd6f6..7d9aca8387e 100644 --- a/src/modules/standard/mod_negotiation.c +++ b/src/modules/standard/mod_negotiation.c @@ -389,10 +389,10 @@ static const char *get_entry(pool *p, accept_rec *result, if (parm[0] == 'q' && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) { - result->quality = atof(cp); + result->quality = (float)atof(cp); } else if (parm[0] == 'l' && !strcmp(&parm[1], "evel")) { - result->level = atof(cp); + result->level = (float)atof(cp); } else if (!strcmp(parm, "charset")) { result->charset = cp; @@ -817,7 +817,7 @@ static int read_type_map(negotiation_state *neg, request_rec *rr) has_content = 1; } else if (!strncmp(buffer, "content-length:", 15)) { - mime_info.bytes = atof(body); + mime_info.bytes = (float)atof(body); has_content = 1; } else if (!strncmp(buffer, "content-language:", 17)) { @@ -1373,7 +1373,7 @@ static void set_language_quality(negotiation_state *neg, var_rec *variant) float fiddle_q = 0.0f; int any_match_on_star = 0; int i, j, alen, longest_lang_range_len; - + for (j = 0; j < variant->content_languages->nelts; ++j) { p = NULL; bestthistag = NULL; @@ -1416,7 +1416,7 @@ static void set_language_quality(negotiation_state *neg, var_rec *variant) alen = strlen(accs[i].name); - if ((strlen(lang) >= alen) && + if (((int)strlen(lang) >= alen) && !strncmp(lang, accs[i].name, alen) && ((lang[alen] == 0) || (lang[alen] == '-')) ) { diff --git a/src/modules/standard/mod_rewrite.c b/src/modules/standard/mod_rewrite.c index ce091f1c6cf..d92b66530e5 100644 --- a/src/modules/standard/mod_rewrite.c +++ b/src/modules/standard/mod_rewrite.c @@ -2475,7 +2475,7 @@ static void reduce_uri(request_rec *r) cp = ap_http_method(r); l = strlen(cp); - if ( strlen(r->filename) > l+3 + if ( (int)strlen(r->filename) > l+3 && strncasecmp(r->filename, cp, l) == 0 && r->filename[l] == ':' && r->filename[l+1] == '/' @@ -3013,7 +3013,7 @@ static int rewrite_rand(int l, int h) * result. Doing an integer modulus would only use the lower-order bits * which may not be as uniformly random. */ - return ((double)(rand() % RAND_MAX) / RAND_MAX) * (h - l + 1) + l; + return (int)((double)(rand() % RAND_MAX) / RAND_MAX) * (h - l + 1) + l; } static char *select_random_value_part(request_rec *r, char *value) diff --git a/src/modules/standard/mod_status.c b/src/modules/standard/mod_status.c index 79f543586ca..03c28f5e508 100644 --- a/src/modules/standard/mod_status.c +++ b/src/modules/standard/mod_status.c @@ -410,12 +410,14 @@ static int status_handler(request_rec *r) (float) count / (float) up_time); if (up_time > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) up_time); + format_byte_out(r, (unsigned long) (KBYTE * (float) kbcount + / (float) up_time)); ap_rputs("/second - ", r); } if (count > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) count); + format_byte_out(r, (unsigned long) (KBYTE * (float) kbcount + / (float) count)); ap_rputs("/request", r); }