[monitoring-plugins] Fix my own errors for real this time and add some ...

RincewindsHat git at monitoring-plugins.org
Thu Oct 28 16:20:12 CEST 2021


 Module: monitoring-plugins
 Branch: master
 Commit: 4c8ab67dd31c526d1c73653319ba537cec3000a5
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Tue Oct 26 21:09:55 2021 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=4c8ab67

Fix my own errors for real this time and add some comments, so I wont do them again

---

 plugins/utils.c | 64 ++++++++++++++++++++++++++++-----------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/plugins/utils.c b/plugins/utils.c
index c0dce25..ebdae2e 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -601,41 +601,39 @@ char *perfdata (const char *label,
 char *perfdata_uint64 (const char *label,
  uint64_t val,
  const char *uom,
-
- int warnp,
+ int warnp, /* Warning present */
  uint64_t warn,
-
- int critp,
+ int critp, /* Critical present */
  uint64_t crit,
-
- int minp,
+ int minp, /* Minimum present */
  uint64_t minv,
-
- int maxp,
+ int maxp, /* Maximum present */
  uint64_t maxv)
 {
 	char *data = NULL;
 
 	if (strpbrk (label, "'= "))
-		xasprintf (&data, "'%s'=%ld%s", label, val, uom);
+		xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
 	else
-		xasprintf (&data, "%s=%ld%s", label, val, uom);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s=%ld%s;", label, val, uom);
 
 	if (warnp)
-		xasprintf (&data, "%s%lu", data, warn);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%lu;", data, warn);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (critp)
-		xasprintf (&data, "%s%lu", data, crit);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%lu;", data, crit);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (minp)
-		xasprintf (&data, "%s%lu", data, minv);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%lu;", data, minv);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (maxp)
-		xasprintf (&data, "%s;%lu", data, maxv);
+		xasprintf (&data, "%s%lu", data, maxv);
 
 	return data;
 }
@@ -644,37 +642,39 @@ char *perfdata_uint64 (const char *label,
 char *perfdata_int64 (const char *label,
  int64_t val,
  const char *uom,
- int warnp,
+ int warnp, /* Warning present */
  int64_t warn,
- int critp,
+ int critp, /* Critical present */
  int64_t crit,
- int minp,
+ int minp, /* Minimum present */
  int64_t minv,
- int maxp,
+ int maxp, /* Maximum present */
  int64_t maxv)
 {
 	char *data = NULL;
 
 	if (strpbrk (label, "'= "))
-		xasprintf (&data, "'%s'=%ld%s", label, val, uom);
+		xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
 	else
-		xasprintf (&data, "%s=%ld%s", label, val, uom);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s=%ld%s;", label, val, uom);
 
 	if (warnp)
-		xasprintf (&data, "%s%ld", data, warn);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%ld;", data, warn);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (critp)
-		xasprintf (&data, "%s%ld", data, crit);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%ld;", data, crit);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (minp)
-		xasprintf (&data, "%s%ld", data, minv);
-	xasprintf (&data, "%s;", data);
+		xasprintf (&data, "%s%ld;", data, minv);
+	else
+		xasprintf (&data, "%s;", data);
 
 	if (maxp)
-		xasprintf (&data, "%s;%ld", data, maxv);
+		xasprintf (&data, "%s%ld", data, maxv);
 
 	return data;
 }



More information about the Commits mailing list