processes plugin: fix build warning
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 23 May 2018 13:41:25 +0000 (15:41 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 23 May 2018 13:41:25 +0000 (15:41 +0200)
src/processes.c:999:24: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
                 tpid) >= sizeof(filename)) {
                 ~~~~~ ^  ~~~~~~~~~~~~~~~~

src/processes.c

index cfc5790..ffe6c5a 100644 (file)
@@ -995,8 +995,9 @@ static int ps_read_tasks_status(process_entry_t *ps) {
 
     tpid = ent->d_name;
 
-    if (snprintf(filename, sizeof(filename), "/proc/%li/task/%s/status", ps->id,
-                 tpid) >= sizeof(filename)) {
+    int r = snprintf(filename, sizeof(filename), "/proc/%li/task/%s/status",
+                     ps->id, tpid);
+    if ((size_t)r >= sizeof(filename)) {
       DEBUG("Filename too long: `%s'", filename);
       continue;
     }