diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-15 15:05:52 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-15 15:05:52 +0100 |
commit | 16075bd2854b2f450483cd3287738855992c18c7 (patch) | |
tree | c384e0bbc21d40b1b9bf2ed49aa77be36d20eea4 | |
parent | 72676bdc14c22818f9154fbee9de54ec6ae61c89 (diff) | |
download | monitoring-plugins-16075bd2854b2f450483cd3287738855992c18c7.tar.gz |
check_swap stuff: make type casts explicit instead of implicit
-rw-r--r-- | plugins/check_swap.d/swap.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/plugins/check_swap.d/swap.c b/plugins/check_swap.d/swap.c index 9133c4fe..ba8c6439 100644 --- a/plugins/check_swap.d/swap.c +++ b/plugins/check_swap.d/swap.c | |||
@@ -313,8 +313,8 @@ swap_result getSwapFromSwapctl_BSD(swap_config config) { | |||
313 | unsigned long long used_swap_mb = 0; | 313 | unsigned long long used_swap_mb = 0; |
314 | 314 | ||
315 | for (int i = 0; i < nswaps; i++) { | 315 | for (int i = 0; i < nswaps; i++) { |
316 | dsktotal_mb = (float)ent[i].se_nblks / config.conversion_factor; | 316 | dsktotal_mb = (float)ent[i].se_nblks / (float)config.conversion_factor; |
317 | dskused_mb = (float)ent[i].se_inuse / config.conversion_factor; | 317 | dskused_mb = (float)ent[i].se_inuse / (float)config.conversion_factor; |
318 | dskfree_mb = (dsktotal_mb - dskused_mb); | 318 | dskfree_mb = (dsktotal_mb - dskused_mb); |
319 | 319 | ||
320 | if (config.allswaps && dsktotal_mb > 0) { | 320 | if (config.allswaps && dsktotal_mb > 0) { |
@@ -325,9 +325,9 @@ swap_result getSwapFromSwapctl_BSD(swap_config config) { | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | total_swap_mb += dsktotal_mb; | 328 | total_swap_mb += (unsigned long long)dsktotal_mb; |
329 | free_swap_mb += dskfree_mb; | 329 | free_swap_mb += (unsigned long long)dskfree_mb; |
330 | used_swap_mb += dskused_mb; | 330 | used_swap_mb += (unsigned long long)dskused_mb; |
331 | } | 331 | } |
332 | 332 | ||
333 | /* and clean up after ourselves */ | 333 | /* and clean up after ourselves */ |
@@ -395,13 +395,13 @@ swap_result getSwapFromSwap_SRV4(swap_config config) { | |||
395 | } | 395 | } |
396 | 396 | ||
397 | /* initialize swap table + entries */ | 397 | /* initialize swap table + entries */ |
398 | swaptbl_t *tbl = (swaptbl_t *)malloc(sizeof(swaptbl_t) + (sizeof(swapent_t) * nswaps)); | 398 | swaptbl_t *tbl = (swaptbl_t *)malloc(sizeof(swaptbl_t) + (sizeof(swapent_t) * (unsigned long)nswaps)); |
399 | 399 | ||
400 | if (tbl == NULL) { | 400 | if (tbl == NULL) { |
401 | die(STATE_UNKNOWN, _("malloc() failed!\n")); | 401 | die(STATE_UNKNOWN, _("malloc() failed!\n")); |
402 | } | 402 | } |
403 | 403 | ||
404 | memset(tbl, 0, sizeof(swaptbl_t) + (sizeof(swapent_t) * nswaps)); | 404 | memset(tbl, 0, sizeof(swaptbl_t) + (sizeof(swapent_t) * (unsigned long)nswaps)); |
405 | tbl->swt_n = nswaps; | 405 | tbl->swt_n = nswaps; |
406 | 406 | ||
407 | for (int i = 0; i < nswaps; i++) { | 407 | for (int i = 0; i < nswaps; i++) { |
@@ -441,9 +441,9 @@ swap_result getSwapFromSwap_SRV4(swap_config config) { | |||
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | total_swap_mb += dsktotal_mb; | 444 | total_swap_mb += (unsigned long long)dsktotal_mb; |
445 | free_swap_mb += dskfree_mb; | 445 | free_swap_mb += (unsigned long long)dskfree_mb; |
446 | used_swap_mb += dskused_mb; | 446 | used_swap_mb += (unsigned long long)dskused_mb; |
447 | } | 447 | } |
448 | 448 | ||
449 | /* and clean up after ourselves */ | 449 | /* and clean up after ourselves */ |