Hello, please review the attached patch
Ilya Shipitsin
From a7f2e5a064c40a5842decc7e053a6e4a4291df33 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin <chipits...@gmail.com> Date: Fri, 6 Apr 2018 17:06:10 +0500 Subject: [PATCH] MINOR: format warnings cleanup issue detected by cppcheck [contrib/base64/base64rev-gen.c:57]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. [contrib/halog/fgets2.c:259]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 6) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1106]: (warning) %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1165]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1194]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 6) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1217]: (warning) %d in format string (no. 9) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1234]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1290]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1290]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [contrib/halog/halog.c:1290]: (warning) %Ld in format string (no. 3) requires 'long long' but the argument type is 'unsigned long long'. [contrib/halog/halog.c:1290]: (warning) %Ld in format string (no. 4) requires 'long long' but the argument type is 'unsigned long long'. [contrib/halog/halog.c:1290]: (warning) %Ld in format string (no. 5) requires 'long long' but the argument type is 'unsigned long long'. [contrib/halog/halog.c:1290]: (warning) %Ld in format string (no. 7) requires 'long long' but the argument type is 'unsigned long long'. [contrib/halog/halog.c:1290]: (warning) %Ld in format string (no. 8) requires 'long long' but the argument type is 'unsigned long long'. [contrib/mod_defender/spoa.c:409]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/mod_defender/spoa.c:869]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/mod_defender/spoa.c:1344]: (warning) %u in format string (no. 4) requires 'unsigned int' but the argument type is 'signed int'. [contrib/mod_defender/spoa.c:1693]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [contrib/modsecurity/spoa.c:414]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/modsecurity/spoa.c:874]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/modsecurity/spoa.c:1373]: (warning) %u in format string (no. 4) requires 'unsigned int' but the argument type is 'signed int'. [contrib/modsecurity/spoa.c:1722]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [contrib/spoa_example/spoa.c:463]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/spoa_example/spoa.c:923]: (warning) %u in format string (no. 5) requires 'unsigned int' but the argument type is 'signed int'. [contrib/spoa_example/spoa.c:1366]: (warning) %u in format string (no. 4) requires 'unsigned int' but the argument type is 'signed int'. [contrib/spoa_example/spoa.c:1715]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'. [src/flt_trace.c:492]: (warning) %u in format string (no. 13) requires 'unsigned int' but the argument type is 'signed int'. [src/hpack-dec.c:173]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [src/peers.c:798]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'. Signed-off-by: Ilya Shipitsin <chipits...@gmail.com> --- contrib/base64/base64rev-gen.c | 2 +- contrib/halog/fgets2.c | 2 +- contrib/halog/halog.c | 12 ++++++------ contrib/mod_defender/spoa.c | 8 ++++---- contrib/modsecurity/spoa.c | 8 ++++---- contrib/spoa_example/spoa.c | 8 ++++---- src/flt_trace.c | 2 +- src/hpack-dec.c | 2 +- src/peers.c | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/contrib/base64/base64rev-gen.c b/contrib/base64/base64rev-gen.c index faffc871..657097ce 100644 --- a/contrib/base64/base64rev-gen.c +++ b/contrib/base64/base64rev-gen.c @@ -16,7 +16,7 @@ const char base64tab[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01 char base64rev[128]; #define base '#' /* arbitrary chosen base value */ -#define B64MAX 64 +#define B64MAX 64U #define B64PADV B64MAX int main() { diff --git a/contrib/halog/fgets2.c b/contrib/halog/fgets2.c index 3db762c6..b6b547f1 100644 --- a/contrib/halog/fgets2.c +++ b/contrib/halog/fgets2.c @@ -256,7 +256,7 @@ int main() { while ((p=fgets2(stdin))) lines++; - printf("lines=%d\n", lines); + printf("lines=%u\n", lines); return 0; } #endif diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c index a7248173..a85957c4 100644 --- a/contrib/halog/halog.c +++ b/contrib/halog/halog.c @@ -1103,7 +1103,7 @@ int main(int argc, char **argv) ms = h % 1000; h = h / 1000; s = h % 60; h = h / 60; m = h % 60; h = h / 60; - printf("%02d:%02d:%02d.%03d %d %d %d\n", h, m, s, ms, last, d, t->count); + printf("%02u:%02u:%02u.%03u %d %u %u\n", h, m, s, ms, last, d, t->count); lines_out++; if (lines_max >= 0 && lines_out >= lines_max) break; @@ -1162,7 +1162,7 @@ int main(int argc, char **argv) for (step = 1; step <= 1000;) { unsigned int thres = lines_out * (step / 1000.0); - printf("%3.1f %d ", step/10.0, thres); + printf("%3.1f %u ", step/10.0, thres); for (f = 1; f < 5; f++) { struct eb32_node *next; while (cum[f] < thres) { @@ -1191,7 +1191,7 @@ int main(int argc, char **argv) n = eb32_first(&timers[0]); while (n) { t = container_of(n, struct timer, node); - printf("%d %d\n", n->key, t->count); + printf("%d %u\n", n->key, t->count); lines_out++; if (lines_max >= 0 && lines_out >= lines_max) break; @@ -1214,7 +1214,7 @@ int main(int argc, char **argv) for (f = 0; f <= 5; f++) tot_rq += srv->st_cnt[f]; - printf("%s %d %d %d %d %d %d %d %d %.1f %d %d\n", + printf("%s %u %u %u %u %u %u %d %u %.1f %d %d\n", srv_node->key, srv->st_cnt[1], srv->st_cnt[2], srv->st_cnt[3], srv->st_cnt[4], srv->st_cnt[5], srv->st_cnt[0], tot_rq, @@ -1231,7 +1231,7 @@ int main(int argc, char **argv) n = eb32_first(&timers[0]); while (n) { t = container_of(n, struct timer, node); - printf("%c%c %d\n", (n->key >> 8), (n->key) & 255, t->count); + printf("%c%c %u\n", (n->key >> 8), (n->key) & 255, t->count); lines_out++; if (lines_max >= 0 && lines_out >= lines_max) break; @@ -1287,7 +1287,7 @@ int main(int argc, char **argv) node = eb_last(&timers[0]); while (node) { ustat = container_of(node, struct url_stat, node.url.node); - printf("%d %d %Ld %Ld %Ld %Ld %Ld %Ld %s\n", + printf("%u %u %Lu %Lu %Lu %Ld %Lu %Lu %s\n", ustat->nb_req, ustat->nb_err, ustat->total_time, diff --git a/contrib/mod_defender/spoa.c b/contrib/mod_defender/spoa.c index c4e15bb4..0d3f029e 100644 --- a/contrib/mod_defender/spoa.c +++ b/contrib/mod_defender/spoa.c @@ -42,7 +42,7 @@ #define DEFAULT_PORT 12345 #define CONNECTION_BACKLOG 10 #define NUM_WORKERS 10 -#define MAX_FRAME_SIZE 16384 +#define MAX_FRAME_SIZE 16384U #define SPOP_VERSION "1.0" #define SLEN(str) (sizeof(str)-1) @@ -406,7 +406,7 @@ check_discon_status_code(struct spoe_frame *frame, char **buf, char *end) frame->client->status_code = (unsigned int)sz; - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", frame->client->id, frame->client->status_code); ret = (p - *buf); @@ -866,7 +866,7 @@ prepare_agentdicon(struct spoe_frame *frame) spoe_encode_buffer("status-code", 11, &p, end); *p++ = SPOE_DATA_T_UINT32; encode_varint(client->status_code, &p, end); - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", client->id, client->status_code); /* "message" K/V item */ @@ -1341,7 +1341,7 @@ process_frame_cb(evutil_socket_t fd, short events, void *arg) p = frame->buf + ret; if (frame->defender_status != -1) { - DEBUG(frame->worker, "Add action : set variable status=%u", + DEBUG(frame->worker, "Add action : set variable status=%d", frame->defender_status); *p++ = SPOE_ACT_T_SET_VAR; /* Action type */ diff --git a/contrib/modsecurity/spoa.c b/contrib/modsecurity/spoa.c index 506ff824..b1a3e976 100644 --- a/contrib/modsecurity/spoa.c +++ b/contrib/modsecurity/spoa.c @@ -47,7 +47,7 @@ #define DEFAULT_PORT 12345 #define CONNECTION_BACKLOG 10 #define NUM_WORKERS 10 -#define MAX_FRAME_SIZE 16384 +#define MAX_FRAME_SIZE 16384U #define SPOP_VERSION "1.0" #define SLEN(str) (sizeof(str)-1) @@ -411,7 +411,7 @@ check_discon_status_code(struct spoe_frame *frame, char **buf, char *end) frame->client->status_code = (unsigned int)sz; - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", frame->client->id, frame->client->status_code); ret = (p - *buf); @@ -871,7 +871,7 @@ prepare_agentdicon(struct spoe_frame *frame) spoe_encode_buffer("status-code", 11, &p, end); *p++ = SPOE_DATA_T_UINT32; encode_varint(client->status_code, &p, end); - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", client->id, client->status_code); /* "message" K/V item */ @@ -1370,7 +1370,7 @@ process_frame_cb(evutil_socket_t fd, short events, void *arg) p = frame->buf + ret; if (frame->modsec_code != -1) { - DEBUG(frame->worker, "Add action : set variable code=%u", + DEBUG(frame->worker, "Add action : set variable code=%d", frame->modsec_code); *p++ = SPOE_ACT_T_SET_VAR; /* Action type */ diff --git a/contrib/spoa_example/spoa.c b/contrib/spoa_example/spoa.c index bf2dbe9a..60c5343a 100644 --- a/contrib/spoa_example/spoa.c +++ b/contrib/spoa_example/spoa.c @@ -42,7 +42,7 @@ #define DEFAULT_PORT 12345 #define CONNECTION_BACKLOG 10 #define NUM_WORKERS 10 -#define MAX_FRAME_SIZE 16384 +#define MAX_FRAME_SIZE 16384U #define SPOP_VERSION "1.0" #define SLEN(str) (sizeof(str)-1) @@ -460,7 +460,7 @@ check_discon_status_code(struct spoe_frame *frame, char **buf, char *end) frame->client->status_code = (unsigned int)sz; - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", frame->client->id, frame->client->status_code); ret = (p - *buf); @@ -920,7 +920,7 @@ prepare_agentdicon(struct spoe_frame *frame) spoe_encode_buffer("status-code", 11, &p, end); *p++ = SPOE_DATA_T_UINT32; encode_varint(client->status_code, &p, end); - DEBUG(frame->worker, "<%lu> Disconnect status code : %u", + DEBUG(frame->worker, "<%lu> Disconnect status code : %d", client->id, client->status_code); /* "message" K/V item */ @@ -1363,7 +1363,7 @@ process_frame_cb(evutil_socket_t fd, short events, void *arg) end = frame->buf+max_frame_size; if (frame->ip_score != -1) { - DEBUG(frame->worker, "Add action : set variable ip_scode=%u", + DEBUG(frame->worker, "Add action : set variable ip_scode=%d", frame->ip_score); *p++ = SPOE_ACT_T_SET_VAR; /* Action type */ diff --git a/src/flt_trace.c b/src/flt_trace.c index fa26de1f..6d4dbb1e 100644 --- a/src/flt_trace.c +++ b/src/flt_trace.c @@ -489,7 +489,7 @@ trace_tcp_data(struct stream *s, struct filter *filter, struct channel *chn) if (ret && conf->rand_parsing) ret = random() % (ret+1); - STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - next=%u - avail=%u - consume=%d", + STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - next=%u - avail=%d - consume=%d", __FUNCTION__, channel_label(chn), proxy_mode(s), stream_pos(s), FLT_NXT(filter, chn), avail, ret); diff --git a/src/hpack-dec.c b/src/hpack-dec.c index 7c3605b6..1baa4795 100644 --- a/src/hpack-dec.c +++ b/src/hpack-dec.c @@ -170,7 +170,7 @@ int hpack_decode_frame(struct hpack_dht *dht, const uint8_t *raw, uint32_t len, if (*raw >= 0x80) { /* indexed header field */ if (*raw == 0x80) { - hpack_debug_printf("unhandled code 0x%02x (raw=%p, len=%d)\n", *raw, raw, len); + hpack_debug_printf("unhandled code 0x%02x (raw=%p, len=%u)\n", *raw, raw, len); ret = -HPACK_ERR_UNKNOWN_OPCODE; goto leave; } diff --git a/src/peers.c b/src/peers.c index c56ed3af..9eccd929 100644 --- a/src/peers.c +++ b/src/peers.c @@ -169,8 +169,8 @@ enum { #define PEER_SESS_SC_ERRPEER 504 /* unknown peer */ #define PEER_SESSION_PROTO_NAME "HAProxyS" -#define PEER_MAJOR_VER 2 -#define PEER_MINOR_VER 1 +#define PEER_MAJOR_VER 2U +#define PEER_MINOR_VER 1U #define PEER_DWNGRD_MINOR_VER 0 struct peers *cfg_peers = NULL; -- 2.14.3