summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.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_swap.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_swap.c')
-rw-r--r--plugins/check_swap.c16
1 files changed, 8 insertions, 8 deletions
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)
129 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 129 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
130 result = max_state (result, check_swap (percent, dskfree_mb)); 130 result = max_state (result, check_swap (percent, dskfree_mb));
131 if (verbose) 131 if (verbose)
132 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 132 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
133 } 133 }
134 } 134 }
135 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp_mb)) { 135 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)
152 free_swap_mb = dskfree_mb; 152 free_swap_mb = dskfree_mb;
153#else 153#else
154# ifdef HAVE_SWAP 154# ifdef HAVE_SWAP
155 asprintf(&swap_command, "%s", SWAP_COMMAND); 155 xasprintf(&swap_command, "%s", SWAP_COMMAND);
156 asprintf(&swap_format, "%s", SWAP_FORMAT); 156 xasprintf(&swap_format, "%s", SWAP_FORMAT);
157 157
158/* These override the command used if a summary (and thus ! allswaps) is required */ 158/* These override the command used if a summary (and thus ! allswaps) is required */
159/* The summary flag returns more accurate information about swap usage on these OSes */ 159/* The summary flag returns more accurate information about swap usage on these OSes */
160# ifdef _AIX 160# ifdef _AIX
161 if (!allswaps) { 161 if (!allswaps) {
162 asprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); 162 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
163 asprintf(&swap_format, "%s", "%f%*s %f"); 163 xasprintf(&swap_format, "%s", "%f%*s %f");
164 conv_factor = 1; 164 conv_factor = 1;
165 } 165 }
166# endif 166# endif
@@ -228,7 +228,7 @@ main (int argc, char **argv)
228 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 228 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
229 result = max_state (result, check_swap (percent, dskfree_mb)); 229 result = max_state (result, check_swap (percent, dskfree_mb));
230 if (verbose) 230 if (verbose)
231 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 231 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
232 } 232 }
233 } 233 }
234# ifdef _AIX 234# ifdef _AIX
@@ -290,7 +290,7 @@ main (int argc, char **argv)
290 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 290 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
291 result = max_state (result, check_swap (percent, dskfree_mb)); 291 result = max_state (result, check_swap (percent, dskfree_mb));
292 if (verbose) { 292 if (verbose) {
293 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 293 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
294 } 294 }
295 } 295 }
296 296
@@ -329,7 +329,7 @@ main (int argc, char **argv)
329 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 329 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
330 result = max_state (result, check_swap (percent, dskfree_mb)); 330 result = max_state (result, check_swap (percent, dskfree_mb));
331 if (verbose) { 331 if (verbose) {
332 asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 332 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent);
333 } 333 }
334 } 334 }
335 335