From 068c124f361d4c615aed79f6fe607f39040b2e31 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Tue, 11 Jul 2023 16:39:29 +0200 Subject: Detect if fmtstr was set in edge cases --- plugins/check_snmp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 425bb7b2..135bbc7c 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -158,6 +158,7 @@ int perf_labels = 1; char* ip_version = ""; double multiplier = 1.0; char *fmtstr = ""; +bool fmtstr_set = false; char buffer[DEFAULT_BUFFER_SIZE]; static char *fix_snmp_range(char *th) @@ -423,7 +424,7 @@ main (int argc, char **argv) else if (strstr (response, "INTEGER: ")) { show = multiply (strstr (response, "INTEGER: ") + 9); - if (strcmp(fmtstr, "") != 0) { + if (fmtstr_set) { conv = fmtstr; } } @@ -973,6 +974,7 @@ process_arguments (int argc, char **argv) case 'f': if (multiplier != 1.0) { fmtstr=optarg; + fmtstr_set = true; } break; } @@ -1187,7 +1189,7 @@ multiply (char *str) if(verbose>2) printf(" multiply extracted double: %f\n", val); val *= multiplier; - if (strcmp(fmtstr, "") != 0) { + if (fmtstr_set) { conv = fmtstr; } if (val == (int)val) { -- cgit v1.2.3-74-g34f1