diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-03-26 13:20:19 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-03-26 13:20:19 +0100 |
commit | abce4d2acc5dcc45965e73c7764e2e4daca2a390 (patch) | |
tree | c26facee561e744ae6eb94b514294e911d8696a7 | |
parent | 066b6e68242b5e7a6f1eb665df9b227d896aec66 (diff) | |
download | monitoring-plugins-abce4d2acc5dcc45965e73c7764e2e4daca2a390.tar.gz |
Fix compiler warnings
-rw-r--r-- | plugins/check_swap.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index bb854beb..65554e8e 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -150,7 +150,7 @@ main (int argc, char **argv) | |||
150 | * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" | 150 | * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" |
151 | * This format exists at least on Debian Linux with a 5.* kernel | 151 | * This format exists at least on Debian Linux with a 5.* kernel |
152 | */ | 152 | */ |
153 | else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_KB)) { | 153 | else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) { |
154 | if (verbose >= 3) { | 154 | if (verbose >= 3) { |
155 | printf("Got %s with %lu\n", str, tmp_KB); | 155 | printf("Got %s with %lu\n", str, tmp_KB); |
156 | } | 156 | } |
@@ -410,7 +410,6 @@ check_swap(float free_swap_mb, float total_swap_mb) | |||
410 | uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100; | 410 | uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100; |
411 | 411 | ||
412 | if (crit.is_percentage && | 412 | if (crit.is_percentage && |
413 | usage_percentage >= 0 && | ||
414 | crit.value != 0 && | 413 | crit.value != 0 && |
415 | usage_percentage >= (100 - crit.value)) | 414 | usage_percentage >= (100 - crit.value)) |
416 | { | 415 | { |
@@ -418,7 +417,6 @@ check_swap(float free_swap_mb, float total_swap_mb) | |||
418 | } | 417 | } |
419 | 418 | ||
420 | if (warn.is_percentage && | 419 | if (warn.is_percentage && |
421 | usage_percentage >= 0 && | ||
422 | warn.value != 0 && | 420 | warn.value != 0 && |
423 | usage_percentage >= (100 - warn.value)) | 421 | usage_percentage >= (100 - warn.value)) |
424 | { | 422 | { |
@@ -475,10 +473,9 @@ process_arguments (int argc, char **argv) | |||
475 | if (is_uint64(optarg, &warn.value)) { | 473 | if (is_uint64(optarg, &warn.value)) { |
476 | if (warn.value > 100) { | 474 | if (warn.value > 100) { |
477 | usage4 (_("Warning threshold percentage must be <= 100!")); | 475 | usage4 (_("Warning threshold percentage must be <= 100!")); |
478 | } else { | ||
479 | break; | ||
480 | } | 476 | } |
481 | } | 477 | } |
478 | break; | ||
482 | } else { | 479 | } else { |
483 | /* It's Bytes */ | 480 | /* It's Bytes */ |
484 | warn.is_percentage = 0; | 481 | warn.is_percentage = 0; |
@@ -506,10 +503,9 @@ process_arguments (int argc, char **argv) | |||
506 | if (is_uint64(optarg, &crit.value)) { | 503 | if (is_uint64(optarg, &crit.value)) { |
507 | if (crit.value> 100) { | 504 | if (crit.value> 100) { |
508 | usage4 (_("Critical threshold percentage must be <= 100!")); | 505 | usage4 (_("Critical threshold percentage must be <= 100!")); |
509 | } else { | ||
510 | break; | ||
511 | } | 506 | } |
512 | } | 507 | } |
508 | break; | ||
513 | } else { | 509 | } else { |
514 | /* It's Bytes */ | 510 | /* It's Bytes */ |
515 | crit.is_percentage = 0; | 511 | crit.is_percentage = 0; |
@@ -527,6 +523,7 @@ process_arguments (int argc, char **argv) | |||
527 | if ((no_swap_state = mp_translate_state(optarg)) == ERROR) { | 523 | if ((no_swap_state = mp_translate_state(optarg)) == ERROR) { |
528 | usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); | 524 | usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); |
529 | } | 525 | } |
526 | break; | ||
530 | case 'v': /* verbose */ | 527 | case 'v': /* verbose */ |
531 | verbose++; | 528 | verbose++; |
532 | break; | 529 | break; |