]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Fix signedness mismatch GCC warnings in few of the plugins
authorEero Tamminen <eero.t.tamminen@intel.com>
Fri, 4 Feb 2022 10:21:51 +0000 (12:21 +0200)
committerEero Tamminen <eero.t.tamminen@intel.com>
Tue, 16 Jan 2024 19:17:02 +0000 (21:17 +0200)
Based on "-O3 -Werror -Wall -Wextra -Wformat-security" output.

src/infiniband.c
src/logparser.c

index c70c824d6fec496d631fcdc17c5662ed5d9cd49c..1069efa368ba2658e1a448e90928058b78a350e7 100644 (file)
@@ -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);
index c326ce865c83f112c61e34f118a2269e3013a729..6317d31d391db7e1c59e3d8eedd58070380a320e 100644 (file)
@@ -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;