[monitoring-plugins] using PRId64 and PRIu64 instead of %ld directly

Andreas Baumann git at monitoring-plugins.org
Fri Oct 21 12:50:11 CEST 2022


 Module: monitoring-plugins
 Branch: pri64
 Commit: f0cc14973498afe8f528437ac799709890d8c402
 Author: Andreas Baumann <mail at andreasbaumann.cc>
   Date: Fri Oct 21 10:45:53 2022 +0000
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=f0cc149

using PRId64 and PRIu64 instead of %ld directly

---

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

diff --git a/plugins/utils.c b/plugins/utils.c
index 17dd581..f75cf03 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -615,27 +615,27 @@ char *perfdata_uint64 (const char *label,
 	char *data = NULL;
 
 	if (strpbrk (label, "'= "))
-		xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
+		xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
 	else
-		xasprintf (&data, "%s=%ld%s;", label, val, uom);
+		xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
 
 	if (warnp)
-		xasprintf (&data, "%s%lu;", data, warn);
+		xasprintf (&data, "%s%" PRIu64 ";", data, warn);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (critp)
-		xasprintf (&data, "%s%lu;", data, crit);
+		xasprintf (&data, "%s%" PRIu64 ";", data, crit);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (minp)
-		xasprintf (&data, "%s%lu;", data, minv);
+		xasprintf (&data, "%s%" PRIu64 ";", data, minv);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (maxp)
-		xasprintf (&data, "%s%lu", data, maxv);
+		xasprintf (&data, "%s%" PRIu64, data, maxv);
 
 	return data;
 }
@@ -656,27 +656,27 @@ char *perfdata_int64 (const char *label,
 	char *data = NULL;
 
 	if (strpbrk (label, "'= "))
-		xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
+		xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
 	else
-		xasprintf (&data, "%s=%ld%s;", label, val, uom);
+		xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
 
 	if (warnp)
-		xasprintf (&data, "%s%ld;", data, warn);
+		xasprintf (&data, "%s%" PRId64 ";", data, warn);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (critp)
-		xasprintf (&data, "%s%ld;", data, crit);
+		xasprintf (&data, "%s%" PRId64 ";", data, crit);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (minp)
-		xasprintf (&data, "%s%ld;", data, minv);
+		xasprintf (&data, "%s%" PRId64 ";", data, minv);
 	else
 		xasprintf (&data, "%s;", data);
 
 	if (maxp)
-		xasprintf (&data, "%s%ld", data, maxv);
+		xasprintf (&data, "%s%" PRId64, data, maxv);
 
 	return data;
 }



More information about the Commits mailing list