[monitoring-plugins] Detect if fmtstr was set in edge cases
Lorenz Kästle
git at monitoring-plugins.org
Tue Sep 19 11:10:12 CEST 2023
Module: monitoring-plugins
Branch: master
Commit: 068c124f361d4c615aed79f6fe607f39040b2e31
Author: Lorenz Kästle <lorenz.kaestle at netways.de>
Date: Tue Jul 11 16:39:29 2023 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=068c124
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 425bb7b..135bbc7 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) {
More information about the Commits
mailing list