From 028d50d6f99e647a325a0a68303016382c4bbdc9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 29 Jun 2012 00:57:48 -0400 Subject: 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 --- plugins/check_swap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'plugins/check_swap.c') diff --git a/plugins/check_swap.c b/plugins/check_swap.c index ce1f6022..1b2a8dd5 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -129,7 +129,7 @@ main (int argc, char **argv) percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); result = max_state (result, check_swap (percent, dskfree_mb)); if (verbose) - asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); } } else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { @@ -152,15 +152,15 @@ main (int argc, char **argv) free_swap_mb = dskfree_mb; #else # ifdef HAVE_SWAP - asprintf(&swap_command, "%s", SWAP_COMMAND); - asprintf(&swap_format, "%s", SWAP_FORMAT); + xasprintf(&swap_command, "%s", SWAP_COMMAND); + xasprintf(&swap_format, "%s", SWAP_FORMAT); /* These override the command used if a summary (and thus ! allswaps) is required */ /* The summary flag returns more accurate information about swap usage on these OSes */ # ifdef _AIX if (!allswaps) { - asprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); - asprintf(&swap_format, "%s", "%f%*s %f"); + xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); + xasprintf(&swap_format, "%s", "%f%*s %f"); conv_factor = 1; } # endif @@ -228,7 +228,7 @@ main (int argc, char **argv) percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); result = max_state (result, check_swap (percent, dskfree_mb)); if (verbose) - asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); } } # ifdef _AIX @@ -290,7 +290,7 @@ main (int argc, char **argv) percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); result = max_state (result, check_swap (percent, dskfree_mb)); if (verbose) { - asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); } } @@ -329,7 +329,7 @@ main (int argc, char **argv) percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); result = max_state (result, check_swap (percent, dskfree_mb)); if (verbose) { - asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); + xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); } } -- cgit v1.2.3-74-g34f1