Просмотр исходного кода

check_disk.c: Fix format-extra-args warning

See,

check_disk.c: In function ‘get_stats’:
check_disk.c:1008:134: warning: format ‘%lu’ expects a matching ‘long unsigned int’ argument [-Wformat=]
 s) used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%lu\n",
                                                                         ~~^
check_disk.c:1028:79: warning: format ‘%li’ expects argument of type ‘long int’, but argument 5 has type ‘char *’ [-Wformat=]
 intf("Group %s now has: used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%lu\n",
                                                                   ~~^
                                                                   %s
      p->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p->best_match->me_mountdir, p->dused_units,
                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
check_disk.c:1028:16: warning: too many arguments for format [-Wformat-extra-args]
         printf("Group %s now has: used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%lu\n",
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mario Trangoni 7 лет назад
Родитель
Сommit
f16266bdd1
1 измененных файлов с 14 добавлено и 13 удалено
  1. 14 13
      plugins/check_disk.c

+ 14 - 13
plugins/check_disk.c

@@ -139,7 +139,7 @@ double c_dfp = -1.0;
 char *path;
 char *exclude_device;
 char *units;
-uintmax_t mult = 1024 * 1024;
+uintmax_t mult = (uintmax_t)1024 * 1024;
 int verbose = 0;
 int newlines = FALSE;
 int erronly = FALSE;
@@ -316,7 +316,7 @@ main (int argc, char **argv)
       get_stats (path, &fsp);
 
       if (verbose >= 3) {
-        printf ("For %s, used_pct=%g free_pct=%g used_units=%li free_units=%li total_units=%li used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n",
+        printf ("For %s, used_pct=%g free_pct=%g used_units=%li free_units=%li total_units=%li used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%ju\n",
           me->me_mountdir, path->dused_pct, path->dfree_pct, path->dused_units, path->dfree_units, path->dtotal_units, path->dused_inodes_percent, path->dfree_inodes_percent, fsp.fsu_blocksize, mult);
       }
 
@@ -608,13 +608,13 @@ process_arguments (int argc, char **argv)
         die (STATE_UNKNOWN, _("failed allocating storage for '%s'\n"), "units");
       break;
     case 'k': /* display mountpoint */
-      mult = 1024;
+      mult = (uintmax_t)1024;
       if (units)
         free(units);
       units = strdup ("kB");
       break;
     case 'm': /* display mountpoint */
-      mult = 1024 * 1024;
+      mult = (uintmax_t)1024 * 1024;
       if (units)
         free(units);
       units = strdup ("MB");
@@ -1005,11 +1005,12 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
         get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
         get_path_stats(p_list, &tmpfsp); 
         if (verbose >= 3)
-          printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%lu\n",
-                 p_list->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, p_list->dfree_units,
-                 p_list->dtotal_units, mult);
+          printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%ju\n", p_list->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize,
+                 p_list->best_match->me_mountdir, p_list->dused_units,
+                 p_list->dfree_units, p_list->dtotal_units,
+                 tmpfsp.fsu_blocksize, mult);
 
-        /* prevent counting the first FS of a group twice since its parameter_list entry 
+        /* prevent counting the first FS of a group twice since its parameter_list entry
          * is used to carry the information of all file systems of the entire group */
         if (! first) {
           p->total += p_list->total;
@@ -1024,10 +1025,10 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
         }
         first = 0;
       }
-      if (verbose >= 3) 
-        printf("Group %s now has: used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%lu\n",
-               p->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p->best_match->me_mountdir, p->dused_units,
-               p->dfree_units, p->dtotal_units, mult);
+      if (verbose >= 3)
+        printf("Group %s now has: used_units=%li free_units=%li total_units=%li fsu_blocksize=%lu mult=%ju\n",
+               p->group, p->dused_units, p->dfree_units, p->dtotal_units,
+               tmpfsp.fsu_blocksize, mult);
     }
     /* modify devname and mountdir for output */
     p->best_match->me_mountdir = p->best_match->me_devname = p->group;
@@ -1055,7 +1056,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
     /* default behaviour : take all the blocks into account */
     p->total = fsp->fsu_blocks;
   }
-  
+
   p->dused_units = p->used*fsp->fsu_blocksize/mult;
   p->dfree_units = p->available*fsp->fsu_blocksize/mult;
   p->dtotal_units = p->total*fsp->fsu_blocksize/mult;