[Nagiosplug-checkins] CVS: nagiosplug/plugins check_disk.c,1.34,1.35 check_dummy.c,1.4,1.5 popen.c,1.5,1.6 utils.c,1.28,1.29 utils.h,1.12,1.13

Karl DeBisschop kdebisschop at users.sourceforge.net
Fri Aug 8 17:42:02 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv2150

Modified Files:
	check_disk.c check_dummy.c popen.c utils.c utils.h 
Log Message:
more pedantic compiler warnings

Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** check_disk.c	8 Aug 2003 16:49:32 -0000	1.34
--- check_disk.c	9 Aug 2003 00:41:05 -0000	1.35
***************
*** 110,114 ****
  
  int process_arguments (int, char **);
! void print_path (char *mypath);
  int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
  int check_disk (double usp, uintmax_t free_disk);
--- 110,114 ----
  
  int process_arguments (int, char **);
! void print_path (const char *mypath);
  int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
  int check_disk (double usp, uintmax_t free_disk);
***************
*** 217,221 ****
  	}
  
! 	die (result, "DISK %s%s\n", state_text (result), output, details);
  	return STATE_UNKNOWN;
  }
--- 217,221 ----
  	}
  
! 	die (result, "DISK %s%s%s\n", state_text (result), output, details);
  	return STATE_UNKNOWN;
  }
***************
*** 454,462 ****
  
  
! void print_path (char *mypath) 
  {
! 	if (mypath)
! 		printf (" for %s", mypath);
! 	printf ("\n");
  }
  
--- 454,466 ----
  
  
! void
! print_path (const char *mypath) 
  {
! 	if (mypath == NULL)
! 		printf ("\n");
! 	else
! 		printf (" for %s\n", mypath);
! 
! 	return;
  }
  
***************
*** 474,478 ****
  INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
  		        cp, wp);
! 		print_path (path);
  		return ERROR;
  	}
--- 478,482 ----
  INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
  		        cp, wp);
! 		print_path (mypath);
  		return ERROR;
  	}
***************
*** 481,485 ****
  INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
  		        (unsigned long)c, (unsigned long)w);
! 		print_path (path);
  		return ERROR;
  	}
--- 485,489 ----
  INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
  		        (unsigned long)c, (unsigned long)w);
! 		print_path (mypath);
  		return ERROR;
  	}
***************
*** 543,546 ****
--- 547,551 ----
  	print_revision (progname, revision);
  
+ 	printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
  	printf (_(COPYRIGHT), copyright, email);
  
***************
*** 597,601 ****
     Checks /tmp and /var at 10%,5% and / at 100MB, 50MB\n"));
  
! 	support ();
  }
  
--- 602,606 ----
     Checks /tmp and /var at 10%,5% and / at 100MB, 50MB\n"));
  
! 	printf (_(UT_SUPPORT));
  }
  

Index: check_dummy.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dummy.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** check_dummy.c	2 Aug 2003 16:42:57 -0000	1.4
--- check_dummy.c	9 Aug 2003 00:41:06 -0000	1.5
***************
*** 1,38 ****
! /*************************************************************
!  *
!  * CHECK_DUMMY.C
!  *
!  * Program: Dummy plugin for Nagios
!  * License: GPL
!  * Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)
!  *
!  * Last Modified: $Date$
!  *
!  * Command line: CHECK_DUMMY <state>
!  *
!  * Description:
!  *
!  * This plugin will simply return the state corresponding to the
!  * numerical value of the <state> argument.
!  *
!  * License Information:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2 of the License, or
!  * (at your option) any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this program; if not, write to the Free Software
!  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!  *
!  **************************************************************/
  
- #include "config.h"
  #include "common.h"
  #include "utils.h"
--- 1,20 ----
! /******************************************************************************
! 
!  This program is free software; you can redistribute it and/or modify
!  it under the terms of the GNU General Public License as published by
!  the Free Software Foundation; either version 2 of the License, or
!  (at your option) any later version.
! 
!  This program is distributed in the hope that it will be useful,
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  GNU General Public License for more details.
! 
!  You should have received a copy of the GNU General Public License
!  along with this program; if not, write to the Free Software
!  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! 
! ******************************************************************************/
  
  #include "common.h"
  #include "utils.h"
***************
*** 43,69 ****
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
! void
! print_usage (void)
! {
! 	printf (_("Usage: %s <integer state>\n"), progname);
! }
! 
! void
! print_help (void)
! {
! 	print_revision (progname, revision);
! 
! 	printf (_(COPYRIGHT), copyright, email);
! 
! 	print_usage ();
! 
! 	printf (_(UT_HELP_VRSN));
  
- 	printf (_("\n\
- This plugin will simply return the state corresponding to the numeric value\n\
- of the <state> argument.\n"));
  
- 	support ();
- }
  
  int
--- 25,32 ----
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
! void print_help (void);
! void print_usage (void);
  
  
  
  int
***************
*** 72,79 ****
  	int result;
  
! 	if (argc != 2) {
! 		printf (_("Incorrect number of arguments supplied\n"));
! 		exit (STATE_UNKNOWN);
! 	}
  	else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  		print_revision (progname, revision);
--- 35,40 ----
  	int result;
  
! 	if (argc != 2)
! 		usage (_("Incorrect number of arguments supplied\n"));
  	else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
  		print_revision (progname, revision);
***************
*** 84,92 ****
  		exit (STATE_OK);
  	}
! 	else if (!is_integer (argv[1])) {
! 		print_usage ();
! 		exit (STATE_UNKNOWN);
! 	}
! 	result = atoi (argv[1]);
  
  	switch (result) {
--- 45,52 ----
  		exit (STATE_OK);
  	}
! 	else if (!is_integer (argv[1]))
! 		usage (_("Arguments to check_dummy must be an integer\n"));
! 	else
! 		result = atoi (argv[1]);
  
  	switch (result) {
***************
*** 100,108 ****
  		printf ("Status is CRITICAL\n");
  		break;
! 	default:
  		printf ("Status is UNKNOWN\n");
! 		result = STATE_UNKNOWN;
  	}
  
  	return result;
  }
--- 60,100 ----
  		printf ("Status is CRITICAL\n");
  		break;
! 	case STATE_UNKNOWN:
  		printf ("Status is UNKNOWN\n");
! 		break;
! 	default:
! 		printf ("Status %d is not a supported error state\n", result);
! 		break;
  	}
  
  	return result;
+ }
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\n\
+ This plugin will simply return the state corresponding to the numeric value\n\
+ of the <state> argument.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage: %s <integer state>\n"), progname);
  }

Index: popen.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/popen.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** popen.c	7 Aug 2003 11:51:12 -0000	1.5
--- popen.c	9 Aug 2003 00:41:06 -0000	1.6
***************
*** 58,64 ****
  #define	max(a,b)	((a) > (b) ? (a) : (b))
  int open_max (void);						/* {Prog openmax} */
! void err_sys (const char *, ...);
  char *rtrim (char *, const char *);
  
  /*int *childerr = NULL;*//* ptr to array allocated at run-time */
  /*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
--- 58,66 ----
  #define	max(a,b)	((a) > (b) ? (a) : (b))
  int open_max (void);						/* {Prog openmax} */
! static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
  char *rtrim (char *, const char *);
  
+ char *pname = NULL;							/* caller can set this from argv[0] */
+ 
  /*int *childerr = NULL;*//* ptr to array allocated at run-time */
  /*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
***************
*** 68,72 ****
  spopen (const char *cmdstring)
  {
! 	char *env[] = { "LC_ALL=C", (char*)0 };
  	char *cmd = NULL;
  	char **argv = NULL;
--- 70,74 ----
  spopen (const char *cmdstring)
  {
! 	char *env[2];
  	char *cmd = NULL;
  	char **argv = NULL;
***************
*** 85,88 ****
--- 87,93 ----
  #endif
  
+ 	env[0] = strdup("LC_ALL=C");
+ 	env[1] = '\0';
+ 
  	/* if no command was passed, return with no error */
  	if (cmdstring == NULL)
***************
*** 149,153 ****
  	if (childpid == NULL) {				/* first time through */
  		maxfd = open_max ();				/* allocate zeroed out array for child pids */
! 		if ((childpid = calloc (maxfd, sizeof (pid_t))) == NULL)
  			return (NULL);
  	}
--- 154,158 ----
  	if (childpid == NULL) {				/* first time through */
  		maxfd = open_max ();				/* allocate zeroed out array for child pids */
! 		if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
  			return (NULL);
  	}
***************
*** 155,159 ****
  	if (child_stderr_array == NULL) {	/* first time through */
  		maxfd = open_max ();				/* allocate zeroed out array for child pids */
! 		if ((child_stderr_array = calloc (maxfd, sizeof (int))) == NULL)
  			return (NULL);
  	}
--- 160,164 ----
  	if (child_stderr_array == NULL) {	/* first time through */
  		maxfd = open_max ();				/* allocate zeroed out array for child pids */
! 		if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL)
  			return (NULL);
  	}
***************
*** 260,291 ****
  
  
- static void err_doit (int, const char *, va_list);
- 
- char *pname = NULL;							/* caller can set this from argv[0] */
  
  /* Fatal error related to a system call.
   * Print a message and die. */
  
- void
- err_sys (const char *fmt, ...)
- {
- 	va_list ap;
- 
- 	va_start (ap, fmt);
- 	err_doit (1, fmt, ap);
- 	va_end (ap);
- 	exit (1);
- }
- 
- /* Print a message and return to caller.
-  * Caller specifies "errnoflag". */
- 
  #define MAXLINE 2048
  static void
! err_doit (int errnoflag, const char *fmt, va_list ap)
  {
  	int errno_save;
  	char buf[MAXLINE];
  
  	errno_save = errno;						/* value caller might want printed */
  	vsprintf (buf, fmt, ap);
--- 265,284 ----
  
  
  
  /* Fatal error related to a system call.
   * Print a message and die. */
  
  #define MAXLINE 2048
  static void
! err_sys (const char *fmt, ...)
  {
+ 	int errnoflag = 1;
  	int errno_save;
  	char buf[MAXLINE];
  
+ 	va_list ap;
+ 
+ 	va_start (ap, fmt);
+ 	/* err_doit (1, fmt, ap); */
  	errno_save = errno;						/* value caller might want printed */
  	vsprintf (buf, fmt, ap);
***************
*** 296,300 ****
  	fputs (buf, stderr);
  	fflush (NULL);								/* flushes all stdio output streams */
! 	return;
  }
  
--- 289,294 ----
  	fputs (buf, stderr);
  	fflush (NULL);								/* flushes all stdio output streams */
! 	va_end (ap);
! 	exit (1);
  }
  
***************
*** 314,315 ****
--- 308,310 ----
  	return str;
  }
+ 

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** utils.c	8 Aug 2003 05:09:40 -0000	1.28
--- utils.c	9 Aug 2003 00:41:06 -0000	1.29
***************
*** 55,59 ****
  void usage (char *msg)
  {
! 	printf (msg);
  	print_usage ();
  	exit (STATE_UNKNOWN);
--- 55,59 ----
  void usage (char *msg)
  {
! 	printf ("%s", msg);
  	print_usage ();
  	exit (STATE_UNKNOWN);

Index: utils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** utils.h	8 Aug 2003 05:09:40 -0000	1.12
--- utils.h	9 Aug 2003 00:41:06 -0000	1.13
***************
*** 17,21 ****
  char *clean_revstring (const char *revstring);
  void print_revision (const char *, const char *);
! void die (int result, const char *fmt, ...) __attribute__((noreturn));
  
  /* Handle timeouts */
--- 17,21 ----
  char *clean_revstring (const char *revstring);
  void print_revision (const char *, const char *);
! void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3)));
  
  /* Handle timeouts */





More information about the Commits mailing list