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
This commit is contained in:
Karl DeBisschop 2003-08-08 05:09:40 +00:00
parent 65ca899d2c
commit a9f992033f
6 changed files with 113 additions and 129 deletions

View file

@ -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"));

View file

@ -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);
}

View file

@ -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 */

View file

@ -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;
}
}

View file

@ -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) {
@ -336,40 +336,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

View file

@ -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))