Commit da21192b authored by valenok's avatar valenok

squashed a warning

parents 07389021 c1e24ac7
...@@ -558,7 +558,7 @@ static void mg_strlcpy(register char *dst, register const char *src, size_t n) { ...@@ -558,7 +558,7 @@ static void mg_strlcpy(register char *dst, register const char *src, size_t n) {
} }
static int lowercase(const char *s) { static int lowercase(const char *s) {
return tolower(* (unsigned char *) s); return tolower(* (const unsigned char *) s);
} }
static int mg_strncasecmp(const char *s1, const char *s2, size_t len) { static int mg_strncasecmp(const char *s1, const char *s2, size_t len) {
...@@ -1281,11 +1281,11 @@ static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf, ...@@ -1281,11 +1281,11 @@ static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf,
if (ssl != NULL) { if (ssl != NULL) {
n = SSL_write(ssl, buf + sent, k); n = SSL_write(ssl, buf + sent, k);
} else if (fp != NULL) { } else if (fp != NULL) {
n = fwrite(buf + sent, 1, k, fp); n = fwrite(buf + sent, 1, (size_t)k, fp);
if (ferror(fp)) if (ferror(fp))
n = -1; n = -1;
} else { } else {
n = send(sock, buf + sent, k, 0); n = send(sock, buf + sent, (size_t)k, 0);
} }
if (n < 0) if (n < 0)
...@@ -1343,7 +1343,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len) { ...@@ -1343,7 +1343,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len) {
if (len < (size_t) buffered_len) { if (len < (size_t) buffered_len) {
buffered_len = len; buffered_len = len;
} }
memcpy(buf, buffered, buffered_len); memcpy(buf, buffered, (size_t)buffered_len);
len -= buffered_len; len -= buffered_len;
buf = (char *) buf + buffered_len; buf = (char *) buf + buffered_len;
conn->consumed_content += buffered_len; conn->consumed_content += buffered_len;
...@@ -1379,7 +1379,7 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) { ...@@ -1379,7 +1379,7 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
len = mg_vsnprintf(conn, buf, sizeof(buf), fmt, ap); len = mg_vsnprintf(conn, buf, sizeof(buf), fmt, ap);
va_end(ap); va_end(ap);
return mg_write(conn, buf, len); return mg_write(conn, buf, (size_t)len);
} }
// URL-decode input buffer into destination buffer. // URL-decode input buffer into destination buffer.
...@@ -1395,10 +1395,10 @@ static size_t url_decode(const char *src, size_t src_len, char *dst, ...@@ -1395,10 +1395,10 @@ static size_t url_decode(const char *src, size_t src_len, char *dst,
for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) { for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
if (src[i] == '%' && if (src[i] == '%' &&
isxdigit(* (unsigned char *) (src + i + 1)) && isxdigit(* (const unsigned char *) (src + i + 1)) &&
isxdigit(* (unsigned char *) (src + i + 2))) { isxdigit(* (const unsigned char *) (src + i + 2))) {
a = tolower(* (unsigned char *) (src + i + 1)); a = tolower(* (const unsigned char *) (src + i + 1));
b = tolower(* (unsigned char *) (src + i + 2)); b = tolower(* (const unsigned char *) (src + i + 2));
dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b)); dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
i += 2; i += 2;
} else if (is_form_url_encoded && src[i] == '+') { } else if (is_form_url_encoded && src[i] == '+') {
...@@ -1436,7 +1436,7 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name, ...@@ -1436,7 +1436,7 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
p += name_len + 1; p += name_len + 1;
// Point s to the end of the value // Point s to the end of the value
s = (const char *) memchr(p, '&', e - p); s = (const char *) memchr(p, '&', (size_t)(e - p));
if (s == NULL) { if (s == NULL) {
s = e; s = e;
} }
...@@ -1444,7 +1444,7 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name, ...@@ -1444,7 +1444,7 @@ int mg_get_var(const char *buf, size_t buf_len, const char *name,
// Decode variable into destination buffer // Decode variable into destination buffer
if ((size_t) (s - p) < dst_len) { if ((size_t) (s - p) < dst_len) {
len = url_decode(p, s - p, dst, dst_len, 1); len = url_decode(p, (size_t)(s - p), dst, dst_len, 1);
} }
break; break;
} }
...@@ -1479,7 +1479,7 @@ int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name, ...@@ -1479,7 +1479,7 @@ int mg_get_cookie(const struct mg_connection *conn, const char *cookie_name,
} }
if ((size_t) (p - s) < dst_size) { if ((size_t) (p - s) < dst_size) {
len = (p - s) + 1; len = (p - s) + 1;
mg_strlcpy(dst, s, len); mg_strlcpy(dst, s, (size_t)len);
} }
break; break;
} }
...@@ -1533,7 +1533,7 @@ static int sslize(struct mg_connection *conn, int (*func)(SSL *)) { ...@@ -1533,7 +1533,7 @@ static int sslize(struct mg_connection *conn, int (*func)(SSL *)) {
func(conn->ssl) == 1; func(conn->ssl) == 1;
} }
struct mg_connection *mg_connect(struct mg_connection *conn, static struct mg_connection *mg_connect(struct mg_connection *conn,
const char *host, int port, int use_ssl) { const char *host, int port, int use_ssl) {
struct mg_connection *newconn = NULL; struct mg_connection *newconn = NULL;
struct sockaddr_in sin; struct sockaddr_in sin;
...@@ -1580,8 +1580,8 @@ static int get_request_len(const char *buf, int buflen) { ...@@ -1580,8 +1580,8 @@ static int get_request_len(const char *buf, int buflen) {
DEBUG_TRACE(("buf: %p, len: %d", buf, buflen)); DEBUG_TRACE(("buf: %p, len: %d", buf, buflen));
for (s = buf, e = s + buflen - 1; len <= 0 && s < e; s++) for (s = buf, e = s + buflen - 1; len <= 0 && s < e; s++)
// Control characters are not allowed but >=128 is. // Control characters are not allowed but >=128 is.
if (!isprint(* (unsigned char *) s) && *s != '\r' && if (!isprint(* (const unsigned char *) s) && *s != '\r' &&
*s != '\n' && * (unsigned char *) s < 128) { *s != '\n' && * (const unsigned char *) s < 128) {
len = -1; len = -1;
} else if (s[0] == '\n' && s[1] == '\n') { } else if (s[0] == '\n' && s[1] == '\n') {
len = (int) (s - buf) + 2; len = (int) (s - buf) + 2;
...@@ -1759,7 +1759,7 @@ typedef struct MD5Context { ...@@ -1759,7 +1759,7 @@ typedef struct MD5Context {
unsigned char in[64]; unsigned char in[64];
} MD5_CTX; } MD5_CTX;
#if __BYTE_ORDER == 1234 #if defined(__BYTE_ORDER) && (__BYTE_ORDER == 1234)
#define byteReverse(buf, len) // Do nothing #define byteReverse(buf, len) // Do nothing
#else #else
static void byteReverse(unsigned char *buf, unsigned longs) { static void byteReverse(unsigned char *buf, unsigned longs) {
...@@ -1963,7 +1963,7 @@ void mg_md5(char *buf, ...) { ...@@ -1963,7 +1963,7 @@ void mg_md5(char *buf, ...) {
va_start(ap, buf); va_start(ap, buf);
while ((p = va_arg(ap, const char *)) != NULL) { while ((p = va_arg(ap, const char *)) != NULL) {
MD5Update(&ctx, (unsigned char *) p, (int) strlen(p)); MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p));
} }
va_end(ap); va_end(ap);
...@@ -2258,13 +2258,13 @@ static void url_encode(const char *src, char *dst, size_t dst_len) { ...@@ -2258,13 +2258,13 @@ static void url_encode(const char *src, char *dst, size_t dst_len) {
const char *end = dst + dst_len - 1; const char *end = dst + dst_len - 1;
for (; *src != '\0' && dst < end; src++, dst++) { for (; *src != '\0' && dst < end; src++, dst++) {
if (isalnum(*(unsigned char *) src) || if (isalnum(*(const unsigned char *) src) ||
strchr(dont_escape, * (unsigned char *) src) != NULL) { strchr(dont_escape, * (const unsigned char *) src) != NULL) {
*dst = *src; *dst = *src;
} else if (dst + 2 < end) { } else if (dst + 2 < end) {
dst[0] = '%'; dst[0] = '%';
dst[1] = hex[(* (unsigned char *) src) >> 4]; dst[1] = hex[(* (const unsigned char *) src) >> 4];
dst[2] = hex[(* (unsigned char *) src) & 0xf]; dst[2] = hex[(* (const unsigned char *) src) & 0xf];
dst += 2; dst += 2;
} }
} }
...@@ -2308,7 +2308,7 @@ static void print_dir_entry(struct de *de) { ...@@ -2308,7 +2308,7 @@ static void print_dir_entry(struct de *de) {
// On windows, __cdecl specification is needed in case if project is built // On windows, __cdecl specification is needed in case if project is built
// with __stdcall convention. qsort always requires __cdels callback. // with __stdcall convention. qsort always requires __cdels callback.
static int WINCDECL compare_dir_entries(const void *p1, const void *p2) { static int WINCDECL compare_dir_entries(const void *p1, const void *p2) {
const struct de *a = (struct de *) p1, *b = (struct de *) p2; const struct de *a = (const struct de *) p1, *b = (const struct de *) p2;
const char *query_string = a->conn->request_info.query_string; const char *query_string = a->conn->request_info.query_string;
int cmp_result = 0; int cmp_result = 0;
...@@ -2410,7 +2410,7 @@ static void handle_directory_request(struct mg_connection *conn, ...@@ -2410,7 +2410,7 @@ static void handle_directory_request(struct mg_connection *conn,
conn->request_info.uri, "..", "Parent directory", "-", "-"); conn->request_info.uri, "..", "Parent directory", "-", "-");
// Sort and print directory entries // Sort and print directory entries
qsort(entries, num_entries, sizeof(entries[0]), compare_dir_entries); qsort(entries, (size_t)num_entries, sizeof(entries[0]), compare_dir_entries);
for (i = 0; i < num_entries; i++) { for (i = 0; i < num_entries; i++) {
print_dir_entry(&entries[i]); print_dir_entry(&entries[i]);
free(entries[i].file_name); free(entries[i].file_name);
...@@ -2433,11 +2433,11 @@ static void send_file_data(struct mg_connection *conn, FILE *fp, int64_t len) { ...@@ -2433,11 +2433,11 @@ static void send_file_data(struct mg_connection *conn, FILE *fp, int64_t len) {
to_read = (int) len; to_read = (int) len;
// Read from file, exit the loop on error // Read from file, exit the loop on error
if ((num_read = fread(buf, 1, to_read, fp)) == 0) if ((num_read = fread(buf, 1, (size_t)to_read, fp)) == 0)
break; break;
// Send read bytes to the client, exit the loop on error // Send read bytes to the client, exit the loop on error
if ((num_written = mg_write(conn, buf, num_read)) != num_read) if ((num_written = mg_write(conn, buf, (size_t)num_read)) != num_read)
break; break;
// Both read and were successful, adjust counters // Both read and were successful, adjust counters
...@@ -2920,7 +2920,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) { ...@@ -2920,7 +2920,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
// Send chunk of data that may be read after the headers // Send chunk of data that may be read after the headers
conn->num_bytes_sent += mg_write(conn, buf + headers_len, conn->num_bytes_sent += mg_write(conn, buf + headers_len,
data_len - headers_len); (size_t)(data_len - headers_len));
// Read the rest of CGI output and send to the client // Read the rest of CGI output and send to the client
send_file_data(conn, out, INT64_MAX); send_file_data(conn, out, INT64_MAX);
...@@ -3101,7 +3101,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path, ...@@ -3101,7 +3101,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path,
assert(len <= (int) sizeof(buf)); assert(len <= (int) sizeof(buf));
if (len < 6 || memcmp(buf, "<!--#", 5) != 0) { if (len < 6 || memcmp(buf, "<!--#", 5) != 0) {
// Not an SSI tag, pass it // Not an SSI tag, pass it
(void) mg_write(conn, buf, len); (void) mg_write(conn, buf, (size_t)len);
} else { } else {
if (!memcmp(buf + 5, "include", 7)) { if (!memcmp(buf + 5, "include", 7)) {
do_ssi_include(conn, path, buf + 12, include_level); do_ssi_include(conn, path, buf + 12, include_level);
...@@ -3126,14 +3126,14 @@ static void send_ssi_file(struct mg_connection *conn, const char *path, ...@@ -3126,14 +3126,14 @@ static void send_ssi_file(struct mg_connection *conn, const char *path,
} else if (ch == '<') { } else if (ch == '<') {
in_ssi_tag = 1; in_ssi_tag = 1;
if (len > 0) { if (len > 0) {
(void) mg_write(conn, buf, len); (void) mg_write(conn, buf, (size_t)len);
} }
len = 0; len = 0;
buf[len++] = ch & 0xff; buf[len++] = ch & 0xff;
} else { } else {
buf[len++] = ch & 0xff; buf[len++] = ch & 0xff;
if (len == (int) sizeof(buf)) { if (len == (int) sizeof(buf)) {
(void) mg_write(conn, buf, len); (void) mg_write(conn, buf, (size_t)len);
len = 0; len = 0;
} }
} }
...@@ -3141,7 +3141,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path, ...@@ -3141,7 +3141,7 @@ static void send_ssi_file(struct mg_connection *conn, const char *path,
// Send the rest of buffered data // Send the rest of buffered data
if (len > 0) { if (len > 0) {
(void) mg_write(conn, buf, len); (void) mg_write(conn, buf, (size_t)len);
} }
} }
...@@ -3176,7 +3176,7 @@ static void handle_request(struct mg_connection *conn) { ...@@ -3176,7 +3176,7 @@ static void handle_request(struct mg_connection *conn) {
* conn->request_info.query_string++ = '\0'; * conn->request_info.query_string++ = '\0';
} }
uri_len = strlen(ri->uri); uri_len = strlen(ri->uri);
(void) url_decode(ri->uri, uri_len, ri->uri, uri_len + 1, 0); (void) url_decode(ri->uri, (size_t)uri_len, ri->uri, (size_t)(uri_len + 1), 0);
remove_double_dots_and_double_slashes(ri->uri); remove_double_dots_and_double_slashes(ri->uri);
convert_uri_to_file_name(conn, ri->uri, path, sizeof(path)); convert_uri_to_file_name(conn, ri->uri, path, sizeof(path));
...@@ -3554,7 +3554,7 @@ static int set_ssl_option(struct mg_context *ctx) { ...@@ -3554,7 +3554,7 @@ static int set_ssl_option(struct mg_context *ctx) {
// Initialize locking callbacks, needed for thread safety. // Initialize locking callbacks, needed for thread safety.
// http://www.openssl.org/support/faq.html#PROG1 // http://www.openssl.org/support/faq.html#PROG1
size = sizeof(pthread_mutex_t) * CRYPTO_num_locks(); size = sizeof(pthread_mutex_t) * CRYPTO_num_locks();
if ((ssl_mutexes = (pthread_mutex_t *) malloc(size)) == NULL) { if ((ssl_mutexes = (pthread_mutex_t *) malloc((size_t)size)) == NULL) {
cry(fc(ctx), "%s: cannot allocate mutexes: %s", __func__, ssl_error()); cry(fc(ctx), "%s: cannot allocate mutexes: %s", __func__, ssl_error());
return 0; return 0;
} }
...@@ -3649,7 +3649,7 @@ static void discard_current_request_from_buffer(struct mg_connection *conn) { ...@@ -3649,7 +3649,7 @@ static void discard_current_request_from_buffer(struct mg_connection *conn) {
} }
conn->data_len -= conn->request_len + body_len; conn->data_len -= conn->request_len + body_len;
memmove(conn->buf, conn->buf + conn->request_len + body_len, conn->data_len); memmove(conn->buf, conn->buf + conn->request_len + body_len, (size_t)conn->data_len);
} }
static int parse_url(const char *url, char *host, int *port) { static int parse_url(const char *url, char *host, int *port) {
...@@ -3712,7 +3712,7 @@ static void handle_proxy_request(struct mg_connection *conn) { ...@@ -3712,7 +3712,7 @@ static void handle_proxy_request(struct mg_connection *conn) {
// Read data from the target and forward it to the client // Read data from the target and forward it to the client
while ((n = pull(NULL, conn->peer->client.sock, conn->peer->ssl, while ((n = pull(NULL, conn->peer->client.sock, conn->peer->ssl,
buf, sizeof(buf))) > 0) { buf, sizeof(buf))) > 0) {
if (mg_write(conn, buf, n) != n) { if (mg_write(conn, buf, (size_t)n) != n) {
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment