diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 05:09:40 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 05:09:40 +0000 |
commit | a9f992033fc32c0cca125e80d3d96aacfc78b802 (patch) | |
tree | bad34ea7077716b4b074ee66ba3259097a4f3108 /plugins | |
parent | 65ca899d2c98b6342783922a5709c4b61e6b2b1f (diff) | |
download | monitoring-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.c | 2 | ||||
-rw-r--r-- | plugins/check_dig.c | 141 | ||||
-rw-r--r-- | plugins/check_disk.c | 49 | ||||
-rw-r--r-- | plugins/check_snmp.c | 2 | ||||
-rw-r--r-- | plugins/utils.c | 38 | ||||
-rw-r--r-- | plugins/utils.h | 10 |
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) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | if (commands > 1) | 293 | if (commands > 1) |
294 | remotecmd = strscat (remotecmd, ";echo STATUS CODE: $?;"); | 294 | asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd); |
295 | 295 | ||
296 | if (remotecmd == NULL || strlen (remotecmd) <= 1) | 296 | if (remotecmd == NULL || strlen (remotecmd) <= 1) |
297 | usage (_("No remotecmd\n")); | 297 | 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 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | |
3 | * This program is free software; you can redistribute it and/or modify | 3 | This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. | 6 | (at your option) any later version. |
7 | * | 7 | |
8 | * This program is distributed in the hope that it will be useful, | 8 | This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | 11 | GNU General Public License for more details. |
12 | * | 12 | |
13 | * You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | |
17 | *****************************************************************************/ | 17 | *****************************************************************************/ |
18 | 18 | ||
19 | #include "config.h" | ||
20 | #include "common.h" | 19 | #include "common.h" |
21 | #include "netutils.h" | 20 | #include "netutils.h" |
22 | #include "utils.h" | 21 | #include "utils.h" |
@@ -36,50 +35,6 @@ enum { | |||
36 | DEFAULT_PORT = 53 | 35 | DEFAULT_PORT = 53 |
37 | }; | 36 | }; |
38 | 37 | ||
39 | void | ||
40 | print_usage (void) | ||
41 | { | ||
42 | printf (_("\ | ||
43 | Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\ | ||
44 | [-c <critical interval>] [-t <timeout>] [-v]\n"), | ||
45 | progname); | ||
46 | printf (" %s (-h|--help)\n", progname); | ||
47 | printf (" %s (-V|--version)\n", progname); | ||
48 | } | ||
49 | |||
50 | void | ||
51 | print_help (void) | ||
52 | { | ||
53 | char *myport; | ||
54 | |||
55 | asprintf (&myport, "%d", DEFAULT_PORT); | ||
56 | |||
57 | print_revision (progname, revision); | ||
58 | |||
59 | printf (_(COPYRIGHT), copyright, email); | ||
60 | |||
61 | printf (_("Test the DNS service on the specified host using dig\n\n")); | ||
62 | |||
63 | print_usage (); | ||
64 | |||
65 | printf (_(UT_HELP_VRSN)); | ||
66 | |||
67 | printf (_(UT_HOST_PORT), 'P', myport); | ||
68 | |||
69 | printf (_("\ | ||
70 | -l, --lookup=STRING\n\ | ||
71 | machine name to lookup\n")); | ||
72 | |||
73 | printf (_(UT_WARN_CRIT)); | ||
74 | |||
75 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
76 | |||
77 | printf (_(UT_VERBOSE)); | ||
78 | |||
79 | support (); | ||
80 | } | ||
81 | |||
82 | |||
83 | char *query_address = NULL; | 38 | char *query_address = NULL; |
84 | char *dns_server = NULL; | 39 | char *dns_server = NULL; |
85 | int verbose = FALSE; | 40 | int verbose = FALSE; |
@@ -88,14 +43,20 @@ int warning_interval = -1; | |||
88 | int critical_interval = -1; | 43 | int critical_interval = -1; |
89 | 44 | ||
90 | 45 | ||
46 | |||
47 | |||
48 | |||
49 | |||
91 | int | 50 | int |
92 | main (int argc, char **argv) | 51 | main (int argc, char **argv) |
93 | { | 52 | { |
94 | char input_buffer[MAX_INPUT_BUFFER]; | 53 | char input_buffer[MAX_INPUT_BUFFER]; |
95 | char *command_line = NULL; | 54 | char *command_line; |
96 | char *output = ""; | 55 | char *output; |
97 | int result = STATE_UNKNOWN; | 56 | int result = STATE_UNKNOWN; |
98 | 57 | ||
58 | output = strdup (""); | ||
59 | |||
99 | /* Set signal handling and alarm */ | 60 | /* Set signal handling and alarm */ |
100 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) | 61 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) |
101 | usage (_("Cannot catch SIGALRM\n")); | 62 | usage (_("Cannot catch SIGALRM\n")); |
@@ -188,6 +149,11 @@ main (int argc, char **argv) | |||
188 | return result; | 149 | return result; |
189 | } | 150 | } |
190 | 151 | ||
152 | |||
153 | |||
154 | |||
155 | |||
156 | |||
191 | /* process command-line arguments */ | 157 | /* process command-line arguments */ |
192 | int | 158 | int |
193 | process_arguments (int argc, char **argv) | 159 | process_arguments (int argc, char **argv) |
@@ -298,4 +264,55 @@ validate_arguments (void) | |||
298 | { | 264 | { |
299 | return OK; | 265 | return OK; |
300 | } | 266 | } |
267 | |||
268 | |||
269 | |||
270 | |||
271 | |||
272 | |||
301 | 273 | ||
274 | void | ||
275 | print_help (void) | ||
276 | { | ||
277 | char *myport; | ||
278 | |||
279 | asprintf (&myport, "%d", DEFAULT_PORT); | ||
280 | |||
281 | print_revision (progname, revision); | ||
282 | |||
283 | printf (_(COPYRIGHT), copyright, email); | ||
284 | |||
285 | printf (_("Test the DNS service on the specified host using dig\n\n")); | ||
286 | |||
287 | print_usage (); | ||
288 | |||
289 | printf (_(UT_HELP_VRSN)); | ||
290 | |||
291 | printf (_(UT_HOST_PORT), 'P', myport); | ||
292 | |||
293 | printf (_("\ | ||
294 | -l, --lookup=STRING\n\ | ||
295 | machine name to lookup\n")); | ||
296 | |||
297 | printf (_(UT_WARN_CRIT)); | ||
298 | |||
299 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
300 | |||
301 | printf (_(UT_VERBOSE)); | ||
302 | |||
303 | support (); | ||
304 | } | ||
305 | |||
306 | |||
307 | |||
308 | |||
309 | void | ||
310 | print_usage (void) | ||
311 | { | ||
312 | printf (_("\ | ||
313 | Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\ | ||
314 | [-c <critical interval>] [-t <timeout>] [-v]\n"), | ||
315 | progname); | ||
316 | printf (" %s (-h|--help)\n", progname); | ||
317 | printf (" %s (-V|--version)\n", progname); | ||
318 | } | ||
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 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * This program is free software; you can redistribute it and/or modify | 3 | This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. | 6 | (at your option) any later version. |
7 | * | 7 | |
8 | * This program is distributed in the hope that it will be useful, | 8 | This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | 11 | GNU General Public License for more details. |
12 | * | 12 | |
13 | * You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | |
17 | *****************************************************************************/ | 17 | *****************************************************************************/ |
18 | 18 | ||
19 | const char *progname = "check_disk"; | 19 | const char *progname = "check_disk"; |
@@ -111,7 +111,7 @@ enum | |||
111 | int process_arguments (int, char **); | 111 | int process_arguments (int, char **); |
112 | void print_path (char *mypath); | 112 | void print_path (char *mypath); |
113 | int validate_arguments (uintmax_t, uintmax_t, double, double, char *); | 113 | int validate_arguments (uintmax_t, uintmax_t, double, double, char *); |
114 | int check_disk (int usp, uintmax_t free_disk); | 114 | int check_disk (double usp, uintmax_t free_disk); |
115 | int walk_name_list (struct name_list *list, const char *name); | 115 | int walk_name_list (struct name_list *list, const char *name); |
116 | void print_help (void); | 116 | void print_help (void); |
117 | void print_usage (void); | 117 | void print_usage (void); |
@@ -120,9 +120,9 @@ uintmax_t w_df = 0; | |||
120 | uintmax_t c_df = 0; | 120 | uintmax_t c_df = 0; |
121 | double w_dfp = -1.0; | 121 | double w_dfp = -1.0; |
122 | double c_dfp = -1.0; | 122 | double c_dfp = -1.0; |
123 | char *path = ""; | 123 | char *path; |
124 | char *exclude_device = ""; | 124 | char *exclude_device; |
125 | char *units = NULL; | 125 | char *units; |
126 | uintmax_t mult = 1024 * 1024; | 126 | uintmax_t mult = 1024 * 1024; |
127 | int verbose = 0; | 127 | int verbose = 0; |
128 | int erronly = FALSE; | 128 | int erronly = FALSE; |
@@ -140,14 +140,17 @@ main (int argc, char **argv) | |||
140 | int result = STATE_UNKNOWN; | 140 | int result = STATE_UNKNOWN; |
141 | int disk_result = STATE_UNKNOWN; | 141 | int disk_result = STATE_UNKNOWN; |
142 | char file_system[MAX_INPUT_BUFFER]; | 142 | char file_system[MAX_INPUT_BUFFER]; |
143 | char *output = ""; | 143 | char *output; |
144 | char *details = ""; | 144 | char *details; |
145 | float free_space, free_space_pct, total_space; | 145 | float free_space, free_space_pct, total_space; |
146 | 146 | ||
147 | struct mount_entry *me; | 147 | struct mount_entry *me; |
148 | struct fs_usage fsp; | 148 | struct fs_usage fsp; |
149 | struct name_list *temp_list; | 149 | struct name_list *temp_list; |
150 | 150 | ||
151 | output = strdup (""); | ||
152 | details = strdup (""); | ||
153 | |||
151 | mount_list = read_filesystem_list (0); | 154 | mount_list = read_filesystem_list (0); |
152 | 155 | ||
153 | if (process_arguments (argc, argv) != OK) | 156 | if (process_arguments (argc, argv) != OK) |
@@ -414,7 +417,7 @@ process_arguments (int argc, char **argv) | |||
414 | if (c_dfp < 0 && argc > c && is_intnonneg (argv[c])) | 417 | if (c_dfp < 0 && argc > c && is_intnonneg (argv[c])) |
415 | c_dfp = (100.0 - atof (argv[c++])); | 418 | c_dfp = (100.0 - atof (argv[c++])); |
416 | 419 | ||
417 | if (argc > c && strlen (path) == 0) { | 420 | if (argc > c && path == NULL) { |
418 | se = (struct name_list *) malloc (sizeof (struct name_list)); | 421 | se = (struct name_list *) malloc (sizeof (struct name_list)); |
419 | se->name = strdup (argv[c++]); | 422 | se->name = strdup (argv[c++]); |
420 | se->name_next = NULL; | 423 | 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 | |||
482 | 485 | ||
483 | 486 | ||
484 | int | 487 | int |
485 | check_disk (int usp, uintmax_t free_disk) | 488 | check_disk (double usp, uintmax_t free_disk) |
486 | { | 489 | { |
487 | int result = STATE_UNKNOWN; | 490 | int result = STATE_UNKNOWN; |
488 | /* check the percent used space against thresholds */ | 491 | /* 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) | |||
201 | ptr = strpbrk (ptr, "\n"); | 201 | ptr = strpbrk (ptr, "\n"); |
202 | } | 202 | } |
203 | if (ptr && strstr (ptr, delimiter) == NULL) { | 203 | if (ptr && strstr (ptr, delimiter) == NULL) { |
204 | response = strscat (response, ptr); | 204 | asprintf (&response, "%s%s", response, ptr); |
205 | ptr = NULL; | 205 | ptr = NULL; |
206 | } | 206 | } |
207 | } | 207 | } |
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) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | void | 69 | void |
70 | usage3 (char *msg, char arg) | 70 | usage3 (char *msg, int arg) |
71 | { | 71 | { |
72 | printf ("%s: %s - %c\n", progname, msg, arg); | 72 | printf ("%s: %s - %c\n", progname, msg, arg); |
73 | print_usage(); | 73 | print_usage(); |
@@ -111,7 +111,7 @@ For more information about these matters, see the file named COPYING.\n")); | |||
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | char * | 114 | const char * |
115 | state_text (int result) | 115 | state_text (int result) |
116 | { | 116 | { |
117 | switch (result) { | 117 | switch (result) { |
@@ -338,40 +338,6 @@ strscpy (char *dest, const char *src) | |||
338 | 338 | ||
339 | /****************************************************************************** | 339 | /****************************************************************************** |
340 | * | 340 | * |
341 | * Concatenates one string to the end of another | ||
342 | * | ||
343 | * Given a pointer destination string, which may or may not already | ||
344 | * hold some text, and a source string with additional text (possibly | ||
345 | * NULL or empty), returns a pointer to a string that is the first | ||
346 | * string with the second concatenated to it. Uses realloc to free | ||
347 | * memory held by the dest argument if new storage space is required. | ||
348 | * | ||
349 | * Example: | ||
350 | * | ||
351 | * char *str=NULL; | ||
352 | * str = strscpy("This is a line of text with no trailing newline"); | ||
353 | * str = strscat(str,"\n"); | ||
354 | * | ||
355 | *****************************************************************************/ | ||
356 | |||
357 | char * | ||
358 | strscat (char *dest, const char *src) | ||
359 | { | ||
360 | |||
361 | if (dest == NULL) | ||
362 | return src; | ||
363 | if (src != NULL) | ||
364 | asprintf (&dest, "%s%s", dest, src); | ||
365 | |||
366 | return dest; | ||
367 | } | ||
368 | |||
369 | |||
370 | |||
371 | |||
372 | |||
373 | /****************************************************************************** | ||
374 | * | ||
375 | * Returns a pointer to the next line of a multiline string buffer | 341 | * Returns a pointer to the next line of a multiline string buffer |
376 | * | 342 | * |
377 | * Given a pointer string, find the text following the next sequence | 343 | * 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)); | |||
22 | 22 | ||
23 | #ifdef LOCAL_TIMEOUT_ALARM_HANDLER | 23 | #ifdef LOCAL_TIMEOUT_ALARM_HANDLER |
24 | extern unsigned int timeout_interval; | 24 | extern unsigned int timeout_interval; |
25 | RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn)); | 25 | RETSIGTYPE timeout_alarm_handler (int); |
26 | #else | 26 | #else |
27 | unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; | 27 | unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; |
28 | extern RETSIGTYPE timeout_alarm_handler (int) __attribute__((noreturn)); | 28 | extern RETSIGTYPE timeout_alarm_handler (int); |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | time_t start_time, end_time; | 31 | time_t start_time, end_time; |
@@ -64,9 +64,7 @@ double delta_time (struct timeval tv); | |||
64 | 64 | ||
65 | void strip (char *buffer); | 65 | void strip (char *buffer); |
66 | char *strscpy (char *dest, const char *src); | 66 | char *strscpy (char *dest, const char *src); |
67 | char *strscat (char *dest, const char *src); | ||
68 | char *strnl (char *str); | 67 | char *strnl (char *str); |
69 | char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ | ||
70 | char *strpcpy (char *dest, const char *src, const char *str); | 68 | char *strpcpy (char *dest, const char *src, const char *str); |
71 | char *strpcat (char *dest, const char *src, const char *str); | 69 | char *strpcat (char *dest, const char *src, const char *str); |
72 | 70 | ||
@@ -74,9 +72,9 @@ int max_state (int a, int b); | |||
74 | 72 | ||
75 | void usage (char *msg) __attribute__((noreturn)); | 73 | void usage (char *msg) __attribute__((noreturn)); |
76 | void usage2(char *msg, char *arg) __attribute__((noreturn)); | 74 | void usage2(char *msg, char *arg) __attribute__((noreturn)); |
77 | void usage3(char *msg, char arg) __attribute__((noreturn)); | 75 | void usage3(char *msg, int arg) __attribute__((noreturn)); |
78 | 76 | ||
79 | char *state_text (int result); | 77 | const char *state_text (int result); |
80 | 78 | ||
81 | #define max(a,b) (((a)>(b))?(a):(b)) | 79 | #define max(a,b) (((a)>(b))?(a):(b)) |
82 | 80 | ||