summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2012-06-29 00:57:48 -0400
committerHolger Weiss <holger@zedat.fu-berlin.de>2012-06-29 13:39:11 +0200
commit028d50d6f99e647a325a0a68303016382c4bbdc9 (patch)
tree1d9a14635602169d137409becfa108cd6bdb371c /plugins/check_disk.c
parent9976876584e5a1df6e1c9315212c3d274df7a12e (diff)
downloadmonitoring-plugins-028d50d6f99e647a325a0a68303016382c4bbdc9.tar.gz
Die when asprintf fails
Fixes many instances of warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f8897647..f8e913e1 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -320,7 +320,7 @@ main (int argc, char **argv)
320 } 320 }
321 321
322 /* Nb: *_high_tide are unset when == UINT_MAX */ 322 /* Nb: *_high_tide are unset when == UINT_MAX */
323 asprintf (&perf, "%s %s", perf, 323 xasprintf (&perf, "%s %s", perf,
324 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 324 perfdata ((!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
325 path->dused_units, units, 325 path->dused_units, units,
326 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide, 326 (warning_high_tide != UINT_MAX ? TRUE : FALSE), warning_high_tide,
@@ -331,20 +331,20 @@ main (int argc, char **argv)
331 if (disk_result==STATE_OK && erronly && !verbose) 331 if (disk_result==STATE_OK && erronly && !verbose)
332 continue; 332 continue;
333 333
334 asprintf (&output, "%s %s %.0f %s (%.0f%%", 334 xasprintf (&output, "%s %s %.0f %s (%.0f%%",
335 output, 335 output,
336 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir, 336 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
337 path->dfree_units, 337 path->dfree_units,
338 units, 338 units,
339 path->dfree_pct); 339 path->dfree_pct);
340 if (path->dused_inodes_percent < 0) { 340 if (path->dused_inodes_percent < 0) {
341 asprintf(&output, "%s inode=-);", output); 341 xasprintf(&output, "%s inode=-);", output);
342 } else { 342 } else {
343 asprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent ); 343 xasprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
344 } 344 }
345 345
346 /* TODO: Need to do a similar debug line 346 /* TODO: Need to do a similar debug line
347 asprintf (&details, _("%s\n\ 347 xasprintf (&details, _("%s\n\
348%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"), 348%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
349 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct, 349 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
350 me->me_devname, me->me_type, me->me_mountdir, 350 me->me_devname, me->me_type, me->me_mountdir,
@@ -356,7 +356,7 @@ main (int argc, char **argv)
356 } 356 }
357 357
358 if (verbose >= 2) 358 if (verbose >= 2)
359 asprintf (&output, "%s%s", output, details); 359 xasprintf (&output, "%s%s", output, details);
360 360
361 361
362 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf); 362 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
@@ -473,13 +473,13 @@ process_arguments (int argc, char **argv)
473 if (*optarg == '@') { 473 if (*optarg == '@') {
474 warn_freespace_percent = optarg; 474 warn_freespace_percent = optarg;
475 } else { 475 } else {
476 asprintf(&warn_freespace_percent, "@%s", optarg); 476 xasprintf(&warn_freespace_percent, "@%s", optarg);
477 } 477 }
478 } else { 478 } else {
479 if (*optarg == '@') { 479 if (*optarg == '@') {
480 warn_freespace_units = optarg; 480 warn_freespace_units = optarg;
481 } else { 481 } else {
482 asprintf(&warn_freespace_units, "@%s", optarg); 482 xasprintf(&warn_freespace_units, "@%s", optarg);
483 } 483 }
484 } 484 }
485 break; 485 break;
@@ -494,13 +494,13 @@ process_arguments (int argc, char **argv)
494 if (*optarg == '@') { 494 if (*optarg == '@') {
495 crit_freespace_percent = optarg; 495 crit_freespace_percent = optarg;
496 } else { 496 } else {
497 asprintf(&crit_freespace_percent, "@%s", optarg); 497 xasprintf(&crit_freespace_percent, "@%s", optarg);
498 } 498 }
499 } else { 499 } else {
500 if (*optarg == '@') { 500 if (*optarg == '@') {
501 crit_freespace_units = optarg; 501 crit_freespace_units = optarg;
502 } else { 502 } else {
503 asprintf(&crit_freespace_units, "@%s", optarg); 503 xasprintf(&crit_freespace_units, "@%s", optarg);
504 } 504 }
505 } 505 }
506 break; 506 break;
@@ -509,14 +509,14 @@ process_arguments (int argc, char **argv)
509 if (*optarg == '@') { 509 if (*optarg == '@') {
510 warn_freeinodes_percent = optarg; 510 warn_freeinodes_percent = optarg;
511 } else { 511 } else {
512 asprintf(&warn_freeinodes_percent, "@%s", optarg); 512 xasprintf(&warn_freeinodes_percent, "@%s", optarg);
513 } 513 }
514 break; 514 break;
515 case 'K': /* critical inode threshold */ 515 case 'K': /* critical inode threshold */
516 if (*optarg == '@') { 516 if (*optarg == '@') {
517 crit_freeinodes_percent = optarg; 517 crit_freeinodes_percent = optarg;
518 } else { 518 } else {
519 asprintf(&crit_freeinodes_percent, "@%s", optarg); 519 xasprintf(&crit_freeinodes_percent, "@%s", optarg);
520 } 520 }
521 break; 521 break;
522 case 'u': 522 case 'u':