aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-08-08 05:09:40 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-08-08 05:09:40 +0000
commita9f992033fc32c0cca125e80d3d96aacfc78b802 (patch)
treebad34ea7077716b4b074ee66ba3259097a4f3108 /plugins
parent65ca899d2c98b6342783922a5709c4b61e6b2b1f (diff)
downloadmonitoring-plugins-a9f992033fc32c0cca125e80d3d96aacfc78b802.tar.gz
fix a variety of compiler warnings about qualifier discards and other pedantic stuff
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@663 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c2
-rw-r--r--plugins/check_dig.c141
-rw-r--r--plugins/check_disk.c49
-rw-r--r--plugins/check_snmp.c2
-rw-r--r--plugins/utils.c38
-rw-r--r--plugins/utils.h10
6 files changed, 113 insertions, 129 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 8527b727..59e8ea0c 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -291,7 +291,7 @@ process_arguments (int argc, char **argv)
}
if (commands > 1)
- remotecmd = strscat (remotecmd, ";echo STATUS CODE: $?;");
+ asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
if (remotecmd == NULL || strlen (remotecmd) <= 1)
usage (_("No remotecmd\n"));
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 3d82298f..7c39a243 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -1,22 +1,21 @@
/*****************************************************************************
-*
-* 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.
-*
+
+ 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 "netutils.h"
#include "utils.h"
@@ -36,50 +35,6 @@ enum {
DEFAULT_PORT = 53
};
-void
-print_usage (void)
-{
- printf (_("\
-Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
- [-c <critical interval>] [-t <timeout>] [-v]\n"),
- progname);
- printf (" %s (-h|--help)\n", progname);
- printf (" %s (-V|--version)\n", progname);
-}
-
-void
-print_help (void)
-{
- char *myport;
-
- asprintf (&myport, "%d", DEFAULT_PORT);
-
- print_revision (progname, revision);
-
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("Test the DNS service on the specified host using dig\n\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_(UT_HOST_PORT), 'P', myport);
-
- printf (_("\
- -l, --lookup=STRING\n\
- machine name to lookup\n"));
-
- printf (_(UT_WARN_CRIT));
-
- printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
-
- printf (_(UT_VERBOSE));
-
- support ();
-}
-
-
char *query_address = NULL;
char *dns_server = NULL;
int verbose = FALSE;
@@ -88,14 +43,20 @@ int warning_interval = -1;
int critical_interval = -1;
+
+
+
+
int
main (int argc, char **argv)
{
char input_buffer[MAX_INPUT_BUFFER];
- char *command_line = NULL;
- char *output = "";
+ char *command_line;
+ char *output;
int result = STATE_UNKNOWN;
+ output = strdup ("");
+
/* Set signal handling and alarm */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
usage (_("Cannot catch SIGALRM\n"));
@@ -188,6 +149,11 @@ main (int argc, char **argv)
return result;
}
+
+
+
+
+
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
@@ -298,4 +264,55 @@ validate_arguments (void)
{
return OK;
}
+
+
+
+
+
+
+void
+print_help (void)
+{
+ char *myport;
+
+ asprintf (&myport, "%d", DEFAULT_PORT);
+
+ print_revision (progname, revision);
+
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("Test the DNS service on the specified host using dig\n\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'P', myport);
+
+ printf (_("\
+ -l, --lookup=STRING\n\
+ machine name to lookup\n"));
+
+ printf (_(UT_WARN_CRIT));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(UT_VERBOSE));
+
+ support ();
+}
+
+
+
+
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
+ [-c <critical interval>] [-t <timeout>] [-v]\n"),
+ progname);
+ printf (" %s (-h|--help)\n", progname);
+ printf (" %s (-V|--version)\n", progname);
+}
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 7feb5a57..7bed4d43 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,19 +1,19 @@
/******************************************************************************
-*
-* 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.
-*
+
+ 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.
+
*****************************************************************************/
const char *progname = "check_disk";
@@ -111,7 +111,7 @@ enum
int process_arguments (int, char **);
void print_path (char *mypath);
int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
-int check_disk (int usp, uintmax_t free_disk);
+int check_disk (double usp, uintmax_t free_disk);
int walk_name_list (struct name_list *list, const char *name);
void print_help (void);
void print_usage (void);
@@ -120,9 +120,9 @@ uintmax_t w_df = 0;
uintmax_t c_df = 0;
double w_dfp = -1.0;
double c_dfp = -1.0;
-char *path = "";
-char *exclude_device = "";
-char *units = NULL;
+char *path;
+char *exclude_device;
+char *units;
uintmax_t mult = 1024 * 1024;
int verbose = 0;
int erronly = FALSE;
@@ -140,14 +140,17 @@ main (int argc, char **argv)
int result = STATE_UNKNOWN;
int disk_result = STATE_UNKNOWN;
char file_system[MAX_INPUT_BUFFER];
- char *output = "";
- char *details = "";
+ char *output;
+ char *details;
float free_space, free_space_pct, total_space;
struct mount_entry *me;
struct fs_usage fsp;
struct name_list *temp_list;
+ output = strdup ("");
+ details = strdup ("");
+
mount_list = read_filesystem_list (0);
if (process_arguments (argc, argv) != OK)
@@ -414,7 +417,7 @@ process_arguments (int argc, char **argv)
if (c_dfp < 0 && argc > c && is_intnonneg (argv[c]))
c_dfp = (100.0 - atof (argv[c++]));
- if (argc > c && strlen (path) == 0) {
+ if (argc > c && path == NULL) {
se = (struct name_list *) malloc (sizeof (struct name_list));
se->name = strdup (argv[c++]);
se->name_next = NULL;
@@ -482,7 +485,7 @@ INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greate
int
-check_disk (int usp, uintmax_t free_disk)
+check_disk (double usp, uintmax_t free_disk)
{
int result = STATE_UNKNOWN;
/* check the percent used space against thresholds */
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index dcb6e68a..e22d8a0b 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -201,7 +201,7 @@ main (int argc, char **argv)
ptr = strpbrk (ptr, "\n");
}
if (ptr && strstr (ptr, delimiter) == NULL) {
- response = strscat (response, ptr);
+ asprintf (&response, "%s%s", response, ptr);
ptr = NULL;
}
}
diff --git a/plugins/utils.c b/plugins/utils.c
index 959541bf..aed03c4e 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -67,7 +67,7 @@ void usage2(char *msg, char *arg)
}
void
-usage3 (char *msg, char arg)
+usage3 (char *msg, int arg)
{
printf ("%s: %s - %c\n", progname, msg, arg);
print_usage();
@@ -111,7 +111,7 @@ For more information about these matters, see the file named COPYING.\n"));
}
-char *
+const char *
state_text (int result)
{
switch (result) {
@@ -338,40 +338,6 @@ strscpy (char *dest, const char *src)
/******************************************************************************
*
- * Concatenates one string to the end of another
- *
- * Given a pointer destination string, which may or may not already
- * hold some text, and a source string with additional text (possibly
- * NULL or empty), returns a pointer to a string that is the first
- * string with the second concatenated to it. Uses realloc to free
- * memory held by the dest argument if new storage space is required.
- *
- * Example:
- *
- * char *str=NULL;
- * str = strscpy("This is a line of text with no trailing newline");
- * str = strscat(str,"\n");
- *
- *****************************************************************************/
-
-char *
-strscat (char *dest, const char *src)
-{
-
- if (dest == NULL)
- return src;
- if (src != NULL)
- asprintf (&dest, "%s%s", dest, src);
-
- return dest;
-}
-
-
-
-
-
-/******************************************************************************
- *
* Returns a pointer to the next line of a multiline string buffer
*
* Given a pointer string, find the text following the next sequence
diff --git a/plugins/utils.h b/plugins/utils.h
index 9dc2654c..a852e86a 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -22,10 +22,10 @@ void die (int result, const char *fmt, ...) __attribute__((noreturn));
#ifdef LOCAL_TIMEOUT_ALARM_HANDLER
extern unsigned int timeout_interval;
-RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn));
+RETSIGTYPE timeout_alarm_handler (int);
#else
unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
-extern RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn));
+extern RETSIGTYPE timeout_alarm_handler (int);
#endif
time_t start_time, end_time;
@@ -64,9 +64,7 @@ double delta_time (struct timeval tv);
void strip (char *buffer);
char *strscpy (char *dest, const char *src);
-char *strscat (char *dest, const char *src);
char *strnl (char *str);
-char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
char *strpcpy (char *dest, const char *src, const char *str);
char *strpcat (char *dest, const char *src, const char *str);
@@ -74,9 +72,9 @@ int max_state (int a, int b);
void usage (char *msg) __attribute__((noreturn));
void usage2(char *msg, char *arg) __attribute__((noreturn));
-void usage3(char *msg, char arg) __attribute__((noreturn));
+void usage3(char *msg, int arg) __attribute__((noreturn));
-char *state_text (int result);
+const char *state_text (int result);
#define max(a,b) (((a)>(b))?(a):(b))