From 4c8ab67dd31c526d1c73653319ba537cec3000a5 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 26 Oct 2021 21:09:55 +0200 Subject: 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 c0dce255..ebdae2e1 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; } -- cgit v1.2.3