[monitoring-plugins] check_icmp: Fix compiler warning

RincewindsHat git at monitoring-plugins.org
Sat Mar 4 21:10:11 CET 2023


 Module: monitoring-plugins
 Branch: master
 Commit: 423284edfa980fc3fdb51ab20af96685a988ba97
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Sun Feb 19 14:34:29 2023 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=423284e

check_icmp: Fix compiler warning

This fixes a compiler warning which complains about an uninitialized
value for a variable which is then returned.
This had no real world impact, since the program would crash in the
branch where result is not set.
The variable is initialized to "-1" which would be the error for
inet_pton.

---

 plugins-root/check_icmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 317cd53..e59e92d 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1339,7 +1339,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
 static int
 add_target(char *arg)
 {
-	int error, result;
+	int error, result = -1;
 	struct sockaddr_storage ip;
 	struct addrinfo hints, *res, *p;
 	struct sockaddr_in *sin;



More information about the Commits mailing list