[Nagiosplug-checkins] nagiosplug/plugins check_game.c,1.24,1.25 check_http.c,1.84,1.85 check_nagios.c,1.27,1.28 check_snmp.c,1.57,1.58 check_swap.c,1.52,1.53 check_tcp.c,1.72,1.73 common.h,1.16,1.17 netutils.c,1.29,1.30 netutils.h,1.15,1.16 sslutils.c,1.1,1.2

M. Sean Finney seanius at users.sourceforge.net
Mon Oct 31 12:04:11 CET 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12760/plugins

Modified Files:
	check_game.c check_http.c check_nagios.c check_snmp.c 
	check_swap.c check_tcp.c common.h netutils.c netutils.h 
	sslutils.c 
Log Message:
code cleanups, largely resulting from turning on -Wall.  mostly
unused variables and explicit casting issues, but there were a
couple gotchas in there too.


Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- check_tcp.c	30 Oct 2005 18:05:19 -0000	1.72
+++ check_tcp.c	31 Oct 2005 20:03:19 -0000	1.73
@@ -31,7 +31,6 @@
 #ifdef HAVE_SSL
 static int check_cert = FALSE;
 static int days_till_exp;
-static char *randbuff = "";
 # define my_recv(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
 # define my_send(buf, len) ((flags & FLAG_SSL) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
 #else
@@ -51,7 +50,6 @@
 static int PROTOCOL = IPPROTO_TCP; /* most common is default */
 static int PORT = 0;
 
-static char timestamp[17] = "";
 static int server_port = 0;
 static char *server_address = NULL;
 static char *server_send = NULL;
@@ -199,7 +197,7 @@
 	if(flags & FLAG_VERBOSE) {
 		printf("Using service %s\n", SERVICE);
 		printf("Port: %d\n", PORT);
-		printf("flags: 0x%x\n", flags);
+		printf("flags: 0x%x\n", (int)flags);
 	}
 
 	if(EXPECT && !server_expect_count)
@@ -242,7 +240,7 @@
 	}
 
 	if(flags & FLAG_VERBOSE) {
-		printf("server_expect_count: %d\n", server_expect_count);
+		printf("server_expect_count: %d\n", (int)server_expect_count);
 		for(i = 0; i < server_expect_count; i++)
 			printf("\t%d: %s\n", i, server_expect[i]);
 	}
@@ -274,7 +272,7 @@
 		/* print raw output if we're debugging */
 		if(flags & FLAG_VERBOSE)
 			printf("received %d bytes from host\n#-raw-recv-------#\n%s\n#-raw-recv-------#\n",
-			       len + 1, status);
+			       (int)len + 1, status);
 		while(isspace(status[len])) status[len--] = '\0';
 
 		for (i = 0; i < server_expect_count; i++) {

Index: common.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/common.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- common.h	19 Oct 2005 12:59:55 -0000	1.16
+++ common.h	31 Oct 2005 20:03:19 -0000	1.17
@@ -45,7 +45,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#ifdef HUGE_VAL_NEEDS_MATH_H
+#ifdef HAVE_MATH_H
 #include <math.h>
 #endif
 

Index: netutils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- netutils.c	25 Oct 2005 10:38:02 -0000	1.29
+++ netutils.c	31 Oct 2005 20:03:19 -0000	1.30
@@ -31,6 +31,8 @@
 *
 ****************************************************************************/
 
+#define LOCAL_TIMEOUT_ALARM_HANDLER
+
 #include "common.h"
 #include "netutils.h"
 
@@ -217,14 +219,14 @@
 	/* else the hostname is interpreted as a path to a unix socket */
 	else {
 		if(strlen(host_name) >= UNIX_PATH_MAX){
-			die(_("Supplied path too long unix domain socket"));
+			die(STATE_UNKNOWN, _("Supplied path too long unix domain socket"));
 		}
 		memset(&su, 0, sizeof(su));
 		su.sun_family = AF_UNIX;
 		strncpy(su.sun_path, host_name, UNIX_PATH_MAX);
 		*sd = socket(PF_UNIX, SOCK_STREAM, 0);
 		if(sd < 0){
-			die(_("Socket creation failed"));
+			die(STATE_UNKNOWN, _("Socket creation failed"));
 		}
 		result = connect(*sd, (struct sockaddr *)&su, sizeof(su));
 		if (result < 0 && errno == ECONNREFUSED)

Index: check_snmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- check_snmp.c	1 Jun 2005 19:41:01 -0000	1.57
+++ check_snmp.c	31 Oct 2005 20:03:19 -0000	1.58
@@ -578,7 +578,7 @@
 				labels_size += 8;
 				labels = realloc (labels, labels_size);
 				if (labels == NULL)
-					die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), nlabels);
+					die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels);
 			}
 			labels[nlabels - 1] = optarg;
 			ptr = thisarg (optarg);
@@ -607,7 +607,7 @@
 				unitv_size += 8;
 				unitv = realloc (unitv, unitv_size);
 				if (unitv == NULL)
-					die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), nunits);
+					die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits);
 			}
 			unitv[nunits - 1] = optarg;
 			ptr = thisarg (optarg);

Index: netutils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- netutils.h	25 Oct 2005 10:38:02 -0000	1.15
+++ netutils.h	31 Oct 2005 20:03:19 -0000	1.16
@@ -37,6 +37,7 @@
 
 #include "config.h"
 #include "common.h"
+#include "utils.h"
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
@@ -77,6 +78,7 @@
 int is_host (const char *);
 int is_addr (const char *);
 int resolve_host_or_addr (const char *, int);
+void host_or_die(const char *str);
 #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
 #ifdef USE_IPV6
 #  define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- check_http.c	19 Oct 2005 20:22:00 -0000	1.84
+++ check_http.c	31 Oct 2005 20:03:19 -0000	1.85
@@ -746,9 +746,6 @@
 	double elapsed_time;
 	int page_len = 0;
 	int result = STATE_UNKNOWN;
-#ifdef HAVE_SSL
-	int sslerr;
-#endif
 
 	/* try to connect to the host at the given port number */
 	if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
@@ -793,7 +790,7 @@
 			asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf);
 		}
 		
-		asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, strlen (http_post_data));
+		asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
 		asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
 	}
 	else {
@@ -858,7 +855,7 @@
 	if (verbose)
 		printf ("%s://%s:%d%s is %d characters\n",
 			use_ssl ? "https" : "http", server_address,
-			server_port, server_url, pagesize);
+			server_port, server_url, (int)pagesize);
 
 	/* find status line and null-terminate it */
 	status_line = page;

Index: check_game.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_game.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- check_game.c	24 Oct 2005 11:10:29 -0000	1.24
+++ check_game.c	31 Oct 2005 20:03:19 -0000	1.25
@@ -56,7 +56,6 @@
 {
 	char *command_line;
 	int result = STATE_UNKNOWN;
-	FILE *fp;
 	char *p, *ret[QSTAT_MAX_RETURN_ARGS];
 	size_t i = 0;
 	output chld_out;

Index: check_nagios.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nagios.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- check_nagios.c	24 Oct 2005 11:10:29 -0000	1.27
+++ check_nagios.c	31 Oct 2005 20:03:19 -0000	1.28
@@ -55,9 +55,9 @@
 	int procrss = 0;
 	float procpcpu = 0;
 	char procstat[8];
-	/* procetime is unused in most configurations, but may be in PS_VAR_LIST
-	 * so it must be here in spite of it producing compiler warnings */
+#ifdef PS_USES_PROCETIME
 	char procetime[MAX_INPUT_BUFFER];
+#endif /* PS_USES_PROCETIME */
 	char procprog[MAX_INPUT_BUFFER];
 	char *procargs;
 	int pos, cols;

Index: sslutils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/sslutils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- sslutils.c	23 Oct 2005 11:59:43 -0000	1.1
+++ sslutils.c	31 Oct 2005 20:03:19 -0000	1.2
@@ -31,6 +31,7 @@
 *
 ****************************************************************************/
 
+#define LOCAL_TIMEOUT_ALARM_HANDLER
 #include "common.h"
 #include "netutils.h"
 

Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- check_swap.c	15 Sep 2005 08:27:58 -0000	1.52
+++ check_swap.c	31 Oct 2005 20:03:19 -0000	1.53
@@ -385,7 +385,7 @@
 			}
 			else if (strstr (optarg, ",") &&
 							 strstr (optarg, "%") &&
-							 sscanf (optarg, "%g,%d%%", &warn_size, &warn_percent) == 2) {
+							 sscanf (optarg, "%lf,%d%%", &warn_size, &warn_percent) == 2) {
 				warn_size = floor(warn_size);
 				break;
 			}
@@ -403,7 +403,7 @@
 			}
 			else if (strstr (optarg, ",") &&
 							 strstr (optarg, "%") &&
-							 sscanf (optarg, "%g,%d%%", &crit_size, &crit_percent) == 2) {
+							 sscanf (optarg, "%lf,%d%%", &crit_size, &crit_percent) == 2) {
 				crit_size = floor(crit_size);
 				break;
 			}





More information about the Commits mailing list