From b245307f555456b6cf9a747bdac6d6ffcd71df29 Mon Sep 17 00:00:00 2001 From: "riccardo@montag" Date: Sun, 5 Sep 2010 13:58:24 +0200 Subject: [PATCH] stricter compiler flags --- http.c | 4 ++-- pyutils.c | 2 +- snmp.c | 31 ++++++++++--------------------- utils.c | 2 +- uwsgi.c | 9 ++++----- uwsgi_pymodule.c | 2 +- uwsgiconfig.py | 2 +- wsgi_handlers.c | 6 +++--- 8 files changed, 23 insertions(+), 35 deletions(-) diff --git a/http.c b/http.c index d1c7d979..76f2bbe9 100644 --- a/http.c +++ b/http.c @@ -216,7 +216,7 @@ static void *http_request(void *u_h_r) uwsgi_error("read()"); break; } - for (i = 0; i < len; i++) { + for (i = 0; i < (int) len; i++) { if (buf[i] == ' ') { @@ -328,7 +328,7 @@ static void *http_request(void *u_h_r) write(uwsgi_fd, uwsgipkt, ulen + 4); if (http_body_len > 0) { - if (http_body_len >= len - (i + 1)) { + if (http_body_len >= (int) len - (i + 1)) { write(uwsgi_fd, buf + i + 1, len - (i + 1)); http_body_len -= len - (i + 1); } else { diff --git a/pyutils.c b/pyutils.c index 3e9f61cd..2048619d 100644 --- a/pyutils.c +++ b/pyutils.c @@ -136,7 +136,7 @@ clear: } if (wsgi_req->async_post && !wsgi_req->fd_closed) { fclose(wsgi_req->async_post); - if (!uwsgi->post_buffering || wsgi_req->post_cl <= uwsgi->post_buffering) { + if (!uwsgi->post_buffering || wsgi_req->post_cl <= (size_t) uwsgi->post_buffering) { wsgi_req->fd_closed = 1 ; } diff --git a/snmp.c b/snmp.c index a808ca42..2b2d8d52 100644 --- a/snmp.c +++ b/snmp.c @@ -39,9 +39,9 @@ void manage_snmp(int fd, uint8_t * buffer, int size, struct sockaddr_in *client_ uint8_t community_len; - uint64_t snmp_int; - uint64_t request_id; - uint64_t version; + uint64_t snmp_int = 0; + uint64_t request_id = 0; + uint64_t version = 0; // KISS for memory management @@ -122,9 +122,7 @@ void manage_snmp(int fd, uint8_t * buffer, int size, struct sockaddr_in *client_ return; ptr++; -uwsgi_log("oops %p\n", ptr); ptrdelta = get_snmp_integer(ptr, &request_id); -uwsgi_log("oops %p\n", ptr); if (ptrdelta <= 0) @@ -139,16 +137,15 @@ uwsgi_log("oops %p\n", ptr); return; ptr += ptrdelta; -uwsgi_log("oops %d %p\n", ptrdelta, ptr); // get error if (*ptr != SNMP_INTEGER) return; -uwsgi_log("oops 2\n"); - ptr++; + snmp_int = 0; ptrdelta = get_snmp_integer(ptr, &snmp_int); + if (ptrdelta <= 0) return; if (ptr + ptrdelta >= buffer + size) @@ -156,15 +153,13 @@ uwsgi_log("oops 2\n"); if (snmp_int != 0) return; -#ifdef UWSGI_DEBUG - uwsgi_debug("SNMP int [0]: %d\n", snmp_int); -#endif ptr += ptrdelta; // get index if (*ptr != SNMP_INTEGER) return; ptr++; + snmp_int = 0; ptrdelta = get_snmp_integer(ptr, &snmp_int); if (ptrdelta <= 0) return; @@ -283,13 +278,15 @@ static int get_snmp_integer(uint8_t * ptr, uint64_t * val) { uint16_t tlen; int i, j; + uint8_t *cval = (uint8_t *) val; + tlen = *ptr; if (tlen > 4) return -1; #ifdef UWSGI_DEBUG - uwsgi_debug("SNMP get integer TLEN %d\n", tlen); + uwsgi_debug("SNMP get integer TLEN %d %p\n", tlen, ptr); #endif j = 0; @@ -297,19 +294,11 @@ static int get_snmp_integer(uint8_t * ptr, uint64_t * val) { for (i = 0; i < tlen; i++) { #else for (i = tlen - 1; i >= 0; i--) { -#ifdef UWSGI_DEBUG - uwsgi_debug("SNMP get integer iter %d %p\n", i, ptr); #endif - -#endif - val[j] = ptr[1 + i]; + cval[j] = ptr[1 + i]; j++; } -#ifdef UWSGI_DEBUG - uwsgi_debug("SNMP get integer iter %d %p\n", i, ptr); -#endif - return tlen + 1; } diff --git a/utils.c b/utils.c index bd6108cc..f0ff7e8b 100644 --- a/utils.c +++ b/utils.c @@ -422,7 +422,7 @@ void env_to_arg(char *src, char *dst) { int i; int val = 0 ; - for(i=0;ipost_buffering > 0 && wsgi_req->post_cl > uwsgi->post_buffering) { + if (uwsgi->post_buffering > 0 && wsgi_req->post_cl > (size_t) uwsgi->post_buffering) { wsgi_req->async_post = tmpfile(); if (!wsgi_req->async_post) { uwsgi_error("tmpfile()"); @@ -264,7 +264,7 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req if (uwsgi->shared->options[UWSGI_OPTION_HARAKIRI] > 0) { inc_harakiri(uwsgi->shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]); } - if (post_remains > uwsgi->post_buffering_bufsize) { + if (post_remains > (size_t) uwsgi->post_buffering_bufsize) { post_chunk = read(wsgi_req->poll.fd, wsgi_req->post_buffering_buf, uwsgi->post_buffering_bufsize); } else { @@ -274,7 +274,7 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req uwsgi_error("read()"); goto clear; } - if (fwrite(wsgi_req->post_buffering_buf, post_chunk, 1, wsgi_req->async_post) <0) { + if (!fwrite(wsgi_req->post_buffering_buf, post_chunk, 1, wsgi_req->async_post)) { uwsgi_error("fwrite()"); goto clear; }