From: Eero Tamminen Date: Fri, 4 Feb 2022 10:21:51 +0000 (+0200) Subject: Fix signedness mismatch GCC warnings in few of the plugins X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e0e724d53f384355301f0ebe21f537c33229ff8;p=thirdparty%2Fcollectd.git Fix signedness mismatch GCC warnings in few of the plugins Based on "-O3 -Werror -Wall -Wextra -Wformat-security" output. --- diff --git a/src/infiniband.c b/src/infiniband.c index c70c824d6..1069efa36 100644 --- a/src/infiniband.c +++ b/src/infiniband.c @@ -118,7 +118,7 @@ static int ib_read_value_file_num_only(const char *device, const char *port, strstripnewline(buffer); // zero-out the first non-digit character - for (int i = 0; i < sizeof(buffer); i++) { + for (size_t i = 0; i < sizeof(buffer); i++) { if (!isdigit(buffer[i])) { buffer[i] = '\0'; break; @@ -327,7 +327,7 @@ static int infiniband_read(void) { char port_name[255]; if (ib_glob_ports(&g) == 0) { - for (int i = 0; i < g.gl_pathc; ++i) { + for (unsigned i = 0; i < g.gl_pathc; ++i) { char *device = NULL, *port = NULL; if (ib_parse_glob_port(g.gl_pathv[i], &device, &port) == 0) { snprintf(port_name, sizeof(port_name), "%s:%s", device, port); diff --git a/src/logparser.c b/src/logparser.c index c326ce865..6317d31d3 100644 --- a/src/logparser.c +++ b/src/logparser.c @@ -401,7 +401,7 @@ static int logparser_validate_config(void) { return -1; } - for (int j = 0; j < parser->patterns_len; j++) { + for (unsigned j = 0; j < parser->patterns_len; j++) { message_pattern_t *pattern = parser->patterns + j; if (pattern->regex == NULL) { @@ -562,7 +562,7 @@ static void logparser_process_msg(log_parser_t *parser, message_t *msg, if (parser->def_type_inst != NULL) sstrncpy(n.type_instance, parser->def_type_inst, sizeof(n.type_instance)); - for (int i = 0; i < max_items; i++) { + for (unsigned i = 0; i < max_items; i++) { message_item_t *item = msg->message_items + i; if (!item->value[0]) break;