[monitoring-plugins] Changing remaining sscanf format specifier to ...

Lorenz Kästle git at monitoring-plugins.org
Mon Jul 24 14:30:12 CEST 2023


 Module: monitoring-plugins
 Branch: master
 Commit: a359667f2b65c06aa60915f03bf89708132b1f8b
 Author: Lorenz Kästle <lorenz.kaestle at netways.de>
   Date: Wed Apr 26 17:52:22 2023 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=a359667

Changing remaining sscanf format specifier to unsigned long

---

 configure.ac         | 10 +++++-----
 plugins/check_swap.c |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index bad5c53..069cc62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1592,13 +1592,13 @@ then
 		grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
 		>/dev/null]
 	then
-		ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
+		ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
 		ac_cv_swap_conv=2048
 		AC_MSG_RESULT([using IRIX format swap])
 
 	elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
 	then
-		ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
+		ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
 		ac_cv_swap_conv=2048
 		AC_MSG_RESULT([using Unixware format swap])
 	else
@@ -1622,7 +1622,7 @@ then
 
 	if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
 	then
-		ac_cv_swap_format=["%*s %f %*d %f"]
+		ac_cv_swap_format=["%*s %lu %*d %lu"]
 		ac_cv_swap_conv=1024
 		AC_MSG_RESULT([using FreeBSD format swapinfo])
 	fi
@@ -1631,7 +1631,7 @@ elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE"
 then
 	ac_cv_have_swap=yes
 	ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
-	ac_cv_swap_format=["%*s %f %*d %f"]
+	ac_cv_swap_format=["%*s %lu %*d %lu"]
 	ac_cv_swap_conv=1024
 	AC_MSG_RESULT([using HP-UX format swapinfo])
 fi
@@ -1646,7 +1646,7 @@ if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
 then
 	ac_cv_have_swap=yes
 	ac_cv_swap_command="$PATH_TO_LSPS -a"
-	ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
+	ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
 	ac_cv_swap_conv=1
 	AC_MSG_RESULT([using AIX lsps])
 fi
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 05f19ad..cd965e3 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -178,7 +178,7 @@ main (int argc, char **argv)
 #  ifdef _AIX
 	if (!allswaps) {
 		xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
-		xasprintf(&swap_format, "%s", "%f%*s %f");
+		xasprintf(&swap_format, "%s", "%lu%*s %lu");
 		conv_factor = 1;
 	}
 #  endif
@@ -205,9 +205,9 @@ main (int argc, char **argv)
 		temp_buffer = strtok (input_buffer, " \n");
 		while (temp_buffer) {
 			if (strstr (temp_buffer, "blocks"))
-				sprintf (str, "%s %s", str, "%f");
+				sprintf (str, "%s %s", str, "%lu");
 			else if (strstr (temp_buffer, "dskfree"))
-				sprintf (str, "%s %s", str, "%f");
+				sprintf (str, "%s %s", str, "%lu");
 			else
 				sprintf (str, "%s %s", str, "%*s");
 			temp_buffer = strtok (NULL, " \n");



More information about the Commits mailing list