From 0289ef264b9e962856b97cb824b4d49b7b556a7d Mon Sep 17 00:00:00 2001 From: Bryan Call Date: Wed, 7 Sep 2016 21:23:12 -0700 Subject: [PATCH] TS-4828: gcc warning comparison between signed and unsigned integer expressions --- plugins/experimental/acme/acme.c | 2 +- .../experimental/remap_purge/remap_purge.c | 2 +- plugins/experimental/ts_lua/ts_lua_fetch.c | 7 ++-- plugins/experimental/url_sig/url_sig.c | 2 +- plugins/stats_over_http/stats_over_http.c | 34 +++++++++---------- tools/http_load/http_load.c | 5 ++- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/experimental/acme/acme.c b/plugins/experimental/acme/acme.c index c9c77294399..b6b46f36760 100644 --- a/plugins/experimental/acme/acme.c +++ b/plugins/experimental/acme/acme.c @@ -264,7 +264,7 @@ acme_hook(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata) const char *path = TSUrlPathGet(reqp, url_loc, &path_len); /* Short circuit the / path, common case */ - if (!path || path_len < (strlen(ACME_WK_PATH) + 2) || *path != '.' || memcmp(path, ACME_WK_PATH, strlen(ACME_WK_PATH))) { + if (!path || path_len < (int)(strlen(ACME_WK_PATH) + 2) || *path != '.' || memcmp(path, ACME_WK_PATH, strlen(ACME_WK_PATH))) { TSDebug(PLUGIN_NAME, "skipping URL path = %.*s", path_len, path); goto cleanup; } diff --git a/plugins/experimental/remap_purge/remap_purge.c b/plugins/experimental/remap_purge/remap_purge.c index a99a1da0a5e..4a20b9046ac 100644 --- a/plugins/experimental/remap_purge/remap_purge.c +++ b/plugins/experimental/remap_purge/remap_purge.c @@ -146,7 +146,7 @@ on_send_response_header(TSHttpTxn txnp, TSCont contp, PurgeInstance *purge) TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_OK); TSHttpHdrReasonSet(bufp, hdr_loc, "OK", 2); - TSHttpTxnErrorBodySet(txnp, TSstrdup(response), len >= sizeof(response) ? sizeof(response) - 1 : len, NULL); + TSHttpTxnErrorBodySet(txnp, TSstrdup(response), len >= (int)sizeof(response) ? (int)sizeof(response) - 1 : len, NULL); TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc); TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); diff --git a/plugins/experimental/ts_lua/ts_lua_fetch.c b/plugins/experimental/ts_lua/ts_lua_fetch.c index eb918b4a4c0..5bb044fec7e 100644 --- a/plugins/experimental/ts_lua/ts_lua_fetch.c +++ b/plugins/experimental/ts_lua/ts_lua_fetch.c @@ -324,13 +324,14 @@ ts_lua_fetch_one_item(lua_State *L, const char *url, size_t url_len, ts_lua_fetc key = luaL_checklstring(L, -1, &key_len); value = luaL_checklstring(L, -2, &value_len); - if (key_len == TS_MIME_LEN_CONTENT_LENGTH && !strncasecmp(TS_MIME_FIELD_CONTENT_LENGTH, key, key_len)) { // Content-Length + if ((int)key_len == TS_MIME_LEN_CONTENT_LENGTH && + !strncasecmp(TS_MIME_FIELD_CONTENT_LENGTH, key, key_len)) { // Content-Length cl = 1; - } else if (key_len == TS_MIME_LEN_HOST && !strncasecmp(TS_MIME_FIELD_HOST, key, key_len)) { // Host + } else if ((int)key_len == TS_MIME_LEN_HOST && !strncasecmp(TS_MIME_FIELD_HOST, key, key_len)) { // Host ht = 1; - } else if (key_len == TS_MIME_LEN_USER_AGENT && !strncasecmp(TS_MIME_FIELD_USER_AGENT, key, key_len)) { // User-Agent + } else if ((int)key_len == TS_MIME_LEN_USER_AGENT && !strncasecmp(TS_MIME_FIELD_USER_AGENT, key, key_len)) { // User-Agent ua = 1; } diff --git a/plugins/experimental/url_sig/url_sig.c b/plugins/experimental/url_sig/url_sig.c index 82171d8ed0e..3991b270606 100644 --- a/plugins/experimental/url_sig/url_sig.c +++ b/plugins/experimental/url_sig/url_sig.c @@ -308,7 +308,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri) int keyindex = -1; int cmp_res; int rval; - int i = 0; + unsigned int i = 0; int j = 0; unsigned int sig_len = 0; diff --git a/plugins/stats_over_http/stats_over_http.c b/plugins/stats_over_http/stats_over_http.c index 5b524d95864..164efe9b451 100644 --- a/plugins/stats_over_http/stats_over_http.c +++ b/plugins/stats_over_http/stats_over_http.c @@ -124,24 +124,24 @@ stats_process_read(TSCont contp, TSEvent event, stats_state *my_state) } #define APPEND(a) my_state->output_bytes += stats_add_data_to_resp_buffer(a, my_state) -#define APPEND_STAT(a, fmt, v) \ - do { \ - char b[256]; \ - if (snprintf(b, sizeof(b), "\"%s\": \"" fmt "\",\n", a, v) < sizeof(b)) \ - APPEND(b); \ +#define APPEND_STAT(a, fmt, v) \ + do { \ + char b[256]; \ + if (snprintf(b, sizeof(b), "\"%s\": \"" fmt "\",\n", a, v) < (int)sizeof(b)) \ + APPEND(b); \ } while (0) -#define APPEND_STAT_NUMERIC(a, fmt, v) \ - do { \ - char b[256]; \ - if (integer_counters) { \ - if (snprintf(b, sizeof(b), "\"%s\": " fmt ",\n", a, v) < sizeof(b)) { \ - APPEND(b); \ - } \ - } else { \ - if (snprintf(b, sizeof(b), "\"%s\": \"" fmt "\",\n", a, v) < sizeof(b)) { \ - APPEND(b); \ - } \ - } \ +#define APPEND_STAT_NUMERIC(a, fmt, v) \ + do { \ + char b[256]; \ + if (integer_counters) { \ + if (snprintf(b, sizeof(b), "\"%s\": " fmt ",\n", a, v) < (int)sizeof(b)) { \ + APPEND(b); \ + } \ + } else { \ + if (snprintf(b, sizeof(b), "\"%s\": \"" fmt "\",\n", a, v) < (int)sizeof(b)) { \ + APPEND(b); \ + } \ + } \ } while (0) // This wraps uint64_t values to the int64_t range to fit into a Java long. Java 8 has an unsigned long which diff --git a/tools/http_load/http_load.c b/tools/http_load/http_load.c index 87d08fcf6bd..55e7f186521 100644 --- a/tools/http_load/http_load.c +++ b/tools/http_load/http_load.c @@ -1178,9 +1178,8 @@ handle_connect(int cnum, struct timeval *nowP, int double_check) if (!RAND_status()) { unsigned char bytes[1024]; - int i; - for (i = 0; i < sizeof(bytes); ++i) - bytes[i] = random() % 0xff; + for (size_t i = 0; i < sizeof(bytes); ++i) + bytes[i] = random() % 0xff; RAND_seed(bytes, sizeof(bytes)); } flags = fcntl(connections[cnum].conn_fd, F_GETFL, 0);