diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:08:13 (GMT) |
---|---|---|
committer | Ton Voon <ton.voon@opsera.com> | 2010-06-24 09:08:13 (GMT) |
commit | 2ad344a47ba80e1c95e554e78b7a1efe0ab0e86b (patch) | |
tree | ea81aacb87a6d93abeec1069b105b3c3c8f2f5b7 /lib | |
parent | 342f3b403e888800fb1b0502bf4e0d8268358573 (diff) | |
download | monitoring-plugins-2ad344a47ba80e1c95e554e78b7a1efe0ab0e86b.tar.gz |
Cleanup some warnings displayed from IRIX tinderbox server
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tests/test_utils.c | 18 | ||||
-rw-r--r-- | lib/utils_base.c | 5 |
2 files changed, 9 insertions, 14 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 5336907..d4a0800 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c | |||
@@ -37,8 +37,6 @@ main (int argc, char **argv) | |||
37 | state_key *temp_state_key = NULL; | 37 | state_key *temp_state_key = NULL; |
38 | state_data *temp_state_data; | 38 | state_data *temp_state_data; |
39 | time_t current_time; | 39 | time_t current_time; |
40 | char *temp_filename; | ||
41 | FILE *temp_fp; | ||
42 | 40 | ||
43 | plan_tests(141); | 41 | plan_tests(141); |
44 | 42 | ||
@@ -342,7 +340,7 @@ main (int argc, char **argv) | |||
342 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/funnykeyname"), "Got internal filename" ); | 340 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/funnykeyname"), "Got internal filename" ); |
343 | ok( temp_state_key->data_version==54, "Version set" ); | 341 | ok( temp_state_key->data_version==54, "Version set" ); |
344 | 342 | ||
345 | temp_state_data = np_state_read(temp_state_key); | 343 | temp_state_data = np_state_read(); |
346 | ok( temp_state_data==NULL, "Got no state data as file does not exist" ); | 344 | ok( temp_state_data==NULL, "Got no state data as file does not exist" ); |
347 | 345 | ||
348 | 346 | ||
@@ -356,31 +354,31 @@ main (int argc, char **argv) | |||
356 | */ | 354 | */ |
357 | 355 | ||
358 | temp_state_key->_filename="var/statefile"; | 356 | temp_state_key->_filename="var/statefile"; |
359 | temp_state_data = np_state_read(temp_state_key); | 357 | temp_state_data = np_state_read(); |
360 | ok( this_nagios_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); | 358 | ok( this_nagios_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); |
361 | ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); | 359 | ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); |
362 | ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); | 360 | ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); |
363 | 361 | ||
364 | temp_state_key->data_version=53; | 362 | temp_state_key->data_version=53; |
365 | temp_state_data = np_state_read(temp_state_key); | 363 | temp_state_data = np_state_read(); |
366 | ok( temp_state_data==NULL, "Older data version gives NULL" ); | 364 | ok( temp_state_data==NULL, "Older data version gives NULL" ); |
367 | temp_state_key->data_version=54; | 365 | temp_state_key->data_version=54; |
368 | 366 | ||
369 | temp_state_key->_filename="var/nonexistant"; | 367 | temp_state_key->_filename="var/nonexistant"; |
370 | temp_state_data = np_state_read(temp_state_key); | 368 | temp_state_data = np_state_read(); |
371 | ok( temp_state_data==NULL, "Missing file gives NULL" ); | 369 | ok( temp_state_data==NULL, "Missing file gives NULL" ); |
372 | ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); | 370 | ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); |
373 | 371 | ||
374 | temp_state_key->_filename="var/oldformat"; | 372 | temp_state_key->_filename="var/oldformat"; |
375 | temp_state_data = np_state_read(temp_state_key); | 373 | temp_state_data = np_state_read(); |
376 | ok( temp_state_data==NULL, "Old file format gives NULL" ); | 374 | ok( temp_state_data==NULL, "Old file format gives NULL" ); |
377 | 375 | ||
378 | temp_state_key->_filename="var/baddate"; | 376 | temp_state_key->_filename="var/baddate"; |
379 | temp_state_data = np_state_read(temp_state_key); | 377 | temp_state_data = np_state_read(); |
380 | ok( temp_state_data==NULL, "Bad date gives NULL" ); | 378 | ok( temp_state_data==NULL, "Bad date gives NULL" ); |
381 | 379 | ||
382 | temp_state_key->_filename="var/missingdataline"; | 380 | temp_state_key->_filename="var/missingdataline"; |
383 | temp_state_data = np_state_read(temp_state_key); | 381 | temp_state_data = np_state_read(); |
384 | ok( temp_state_data==NULL, "Missing data line gives NULL" ); | 382 | ok( temp_state_data==NULL, "Missing data line gives NULL" ); |
385 | 383 | ||
386 | 384 | ||
@@ -413,7 +411,7 @@ main (int argc, char **argv) | |||
413 | temp_state_key->_filename="var/generated"; | 411 | temp_state_key->_filename="var/generated"; |
414 | time(¤t_time); | 412 | time(¤t_time); |
415 | np_state_write_string(0, "String to read"); | 413 | np_state_write_string(0, "String to read"); |
416 | temp_state_data = np_state_read(temp_state_key); | 414 | temp_state_data = np_state_read(); |
417 | /* Check time is set to current_time */ | 415 | /* Check time is set to current_time */ |
418 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); | 416 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); |
419 | ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); | 417 | ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); |
diff --git a/lib/utils_base.c b/lib/utils_base.c index 6de92cb..1f705d9 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
@@ -471,10 +471,8 @@ void np_enable_state(char *keyname, int expected_data_version) { | |||
471 | * if exceptional error. | 471 | * if exceptional error. |
472 | */ | 472 | */ |
473 | state_data *np_state_read() { | 473 | state_data *np_state_read() { |
474 | state_key *my_state_key; | ||
475 | state_data *this_state_data=NULL; | 474 | state_data *this_state_data=NULL; |
476 | FILE *statefile; | 475 | FILE *statefile; |
477 | int c; | ||
478 | int rc = FALSE; | 476 | int rc = FALSE; |
479 | 477 | ||
480 | if(this_nagios_plugin==NULL) | 478 | if(this_nagios_plugin==NULL) |
@@ -508,7 +506,7 @@ state_data *np_state_read() { | |||
508 | * Read the state file | 506 | * Read the state file |
509 | */ | 507 | */ |
510 | int _np_state_read_file(FILE *f) { | 508 | int _np_state_read_file(FILE *f) { |
511 | int c, status=FALSE; | 509 | int status=FALSE; |
512 | size_t pos; | 510 | size_t pos; |
513 | char *line; | 511 | char *line; |
514 | int i; | 512 | int i; |
@@ -585,7 +583,6 @@ void np_state_write_string(time_t data_time, char *data_string) { | |||
585 | char *temp_file=NULL; | 583 | char *temp_file=NULL; |
586 | int fd=0, result=0; | 584 | int fd=0, result=0; |
587 | time_t current_time; | 585 | time_t current_time; |
588 | size_t len; | ||
589 | char *directories=NULL; | 586 | char *directories=NULL; |
590 | char *p=NULL; | 587 | char *p=NULL; |
591 | 588 | ||