diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-08-29 10:50:53 +0200 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-08-29 10:50:53 +0200 |
commit | 1ca5a6040a01cb5fc4f1ceb61b133826b22e1f7b (patch) | |
tree | 17bb66ca20b7bf86c23fe6a12fab2ce936daaf4b /plugins | |
parent | b4d84ebfee2cc93935ffead1f09a83ab0005ea10 (diff) | |
download | monitoring-plugins-1ca5a6040a01cb5fc4f1ceb61b133826b22e1f7b.tar.gz |
check_snmp: Make linter happy
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_snmp.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 1f4acb5a..0c1e8ebe 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -36,7 +36,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
36 | #include "./runcmd.h" | 36 | #include "./runcmd.h" |
37 | #include "./utils.h" | 37 | #include "./utils.h" |
38 | #include "../lib/states.h" | 38 | #include "../lib/states.h" |
39 | #include "../lib/utils_cmd.h" | 39 | |
40 | #include "../lib/thresholds.h" | 40 | #include "../lib/thresholds.h" |
41 | #include "../lib/utils_base.h" | 41 | #include "../lib/utils_base.h" |
42 | #include "../lib/output.h" | 42 | #include "../lib/output.h" |
@@ -159,7 +159,8 @@ int main(int argc, char **argv) { | |||
159 | } | 159 | } |
160 | 160 | ||
161 | const int timeout_safety_tolerance = 5; | 161 | const int timeout_safety_tolerance = 5; |
162 | alarm(timeout_interval * config.snmp_session.retries + timeout_safety_tolerance); | 162 | alarm((timeout_interval * (unsigned int)config.snmp_session.retries) + |
163 | timeout_safety_tolerance); | ||
163 | 164 | ||
164 | struct snmp_session *active_session = snmp_open(&config.snmp_session); | 165 | struct snmp_session *active_session = snmp_open(&config.snmp_session); |
165 | if (active_session == NULL) { | 166 | if (active_session == NULL) { |
@@ -254,7 +255,7 @@ int main(int argc, char **argv) { | |||
254 | sc_oid_test, (config.invert_search) ? STATE_OK : STATE_CRITICAL); | 255 | sc_oid_test, (config.invert_search) ? STATE_OK : STATE_CRITICAL); |
255 | } | 256 | } |
256 | } else if (config.test_units[loop_index].eval_mthd.crit_regex) { | 257 | } else if (config.test_units[loop_index].eval_mthd.crit_regex) { |
257 | const int nmatch = config.regex_cmp_value.re_nsub + 1; | 258 | const size_t nmatch = config.regex_cmp_value.re_nsub + 1; |
258 | regmatch_t pmatch[nmatch]; | 259 | regmatch_t pmatch[nmatch]; |
259 | memset(pmatch, '\0', sizeof(regmatch_t) * nmatch); | 260 | memset(pmatch, '\0', sizeof(regmatch_t) * nmatch); |
260 | 261 | ||
@@ -287,8 +288,8 @@ int main(int argc, char **argv) { | |||
287 | } | 288 | } |
288 | struct counter64 tmp = *(vars->val.counter64); | 289 | struct counter64 tmp = *(vars->val.counter64); |
289 | uint64_t counter = (tmp.high << 32) + tmp.low; | 290 | uint64_t counter = (tmp.high << 32) + tmp.low; |
290 | counter *= config.multiplier; | 291 | counter *= (uint64_t)config.multiplier; |
291 | counter += config.offset; | 292 | counter += (uint64_t)config.offset; |
292 | pd_result_val = mp_create_pd_value(counter); | 293 | pd_result_val = mp_create_pd_value(counter); |
293 | } break; | 294 | } break; |
294 | /* Numerical values */ | 295 | /* Numerical values */ |
@@ -299,10 +300,10 @@ int main(int argc, char **argv) { | |||
299 | if (verbose) { | 300 | if (verbose) { |
300 | printf("Debug: Got a Integer like\n"); | 301 | printf("Debug: Got a Integer like\n"); |
301 | } | 302 | } |
302 | unsigned long tmp = *(vars->val.integer); | 303 | unsigned long tmp = (unsigned long)*(vars->val.integer); |
303 | tmp *= config.multiplier; | 304 | tmp *= (unsigned long)config.multiplier; |
304 | 305 | ||
305 | tmp += config.offset; | 306 | tmp += (unsigned long)config.offset; |
306 | pd_result_val = mp_create_pd_value(tmp); | 307 | pd_result_val = mp_create_pd_value(tmp); |
307 | break; | 308 | break; |
308 | } | 309 | } |
@@ -310,17 +311,18 @@ int main(int argc, char **argv) { | |||
310 | if (verbose) { | 311 | if (verbose) { |
311 | printf("Debug: Got a Integer\n"); | 312 | printf("Debug: Got a Integer\n"); |
312 | } | 313 | } |
313 | unsigned long tmp = *(vars->val.integer); | ||
314 | tmp *= config.multiplier; | ||
315 | 314 | ||
316 | tmp += config.offset; | 315 | long tmp = *(vars->val.integer); |
316 | tmp *= (long)config.multiplier; | ||
317 | tmp += (long)config.offset; | ||
318 | |||
317 | pd_result_val = mp_create_pd_value(tmp); | 319 | pd_result_val = mp_create_pd_value(tmp); |
318 | } break; | 320 | } break; |
319 | case ASN_FLOAT: { | 321 | case ASN_FLOAT: { |
320 | if (verbose) { | 322 | if (verbose) { |
321 | printf("Debug: Got a float\n"); | 323 | printf("Debug: Got a float\n"); |
322 | } | 324 | } |
323 | float tmp = *(vars->val.floatVal); | 325 | double tmp = *(vars->val.floatVal); |
324 | tmp *= config.multiplier; | 326 | tmp *= config.multiplier; |
325 | 327 | ||
326 | tmp += config.offset; | 328 | tmp += config.offset; |
@@ -437,7 +439,7 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
437 | {"ipv4", no_argument, 0, '4'}, | 439 | {"ipv4", no_argument, 0, '4'}, |
438 | {"ipv6", no_argument, 0, '6'}, | 440 | {"ipv6", no_argument, 0, '6'}, |
439 | {"multiplier", required_argument, 0, 'M'}, | 441 | {"multiplier", required_argument, 0, 'M'}, |
440 | {"ignore-mib-parsing-errors", no_argument, false, L_IGNORE_MIB_PARSING_ERRORS}, | 442 | {"ignore-mib-parsing-errors", no_argument, 0, L_IGNORE_MIB_PARSING_ERRORS}, |
441 | {"connection-prefix", required_argument, 0, L_CONNECTION_PREFIX}, | 443 | {"connection-prefix", required_argument, 0, L_CONNECTION_PREFIX}, |
442 | {0, 0, 0, 0}}; | 444 | {0, 0, 0, 0}}; |
443 | 445 | ||
@@ -674,7 +676,7 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
674 | if (!is_integer(optarg)) { | 676 | if (!is_integer(optarg)) { |
675 | usage2(_("Timeout interval must be a positive integer"), optarg); | 677 | usage2(_("Timeout interval must be a positive integer"), optarg); |
676 | } else { | 678 | } else { |
677 | timeout_interval = atoi(optarg); | 679 | timeout_interval = (unsigned int)atoi(optarg); |
678 | } | 680 | } |
679 | break; | 681 | break; |
680 | 682 | ||
@@ -895,10 +897,12 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
895 | "No authentication passphrase was given, but authorization was requested"); | 897 | "No authentication passphrase was given, but authorization was requested"); |
896 | } | 898 | } |
897 | // auth and priv | 899 | // auth and priv |
898 | size_t priv_key_generated = generate_Ku( | 900 | int priv_key_generated = |
899 | config.snmp_session.securityPrivProto, config.snmp_session.securityPrivProtoLen, | 901 | generate_Ku(config.snmp_session.securityPrivProto, |
900 | authpasswd, strlen((const char *)authpasswd), config.snmp_session.securityPrivKey, | 902 | (unsigned int)config.snmp_session.securityPrivProtoLen, authpasswd, |
901 | &config.snmp_session.securityPrivKeyLen); | 903 | strlen((const char *)authpasswd), config.snmp_session.securityPrivKey, |
904 | &config.snmp_session.securityPrivKeyLen); | ||
905 | |||
902 | if (priv_key_generated != SNMPERR_SUCCESS) { | 906 | if (priv_key_generated != SNMPERR_SUCCESS) { |
903 | die(STATE_UNKNOWN, "Failed to generate privacy key"); | 907 | die(STATE_UNKNOWN, "Failed to generate privacy key"); |
904 | } | 908 | } |
@@ -908,10 +912,12 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
908 | if (privpasswd == NULL) { | 912 | if (privpasswd == NULL) { |
909 | die(STATE_UNKNOWN, "No privacy passphrase was given, but privacy was requested"); | 913 | die(STATE_UNKNOWN, "No privacy passphrase was given, but privacy was requested"); |
910 | } | 914 | } |
911 | size_t auth_key_generated = generate_Ku( | 915 | int auth_key_generated = |
912 | config.snmp_session.securityAuthProto, config.snmp_session.securityAuthProtoLen, | 916 | generate_Ku(config.snmp_session.securityAuthProto, |
913 | privpasswd, strlen((const char *)privpasswd), config.snmp_session.securityAuthKey, | 917 | (unsigned int)config.snmp_session.securityAuthProtoLen, privpasswd, |
914 | &config.snmp_session.securityAuthKeyLen); | 918 | strlen((const char *)privpasswd), config.snmp_session.securityAuthKey, |
919 | &config.snmp_session.securityAuthKeyLen); | ||
920 | |||
915 | if (auth_key_generated != SNMPERR_SUCCESS) { | 921 | if (auth_key_generated != SNMPERR_SUCCESS) { |
916 | die(STATE_UNKNOWN, "Failed to generate privacy key"); | 922 | die(STATE_UNKNOWN, "Failed to generate privacy key"); |
917 | } | 923 | } |