[nagiosplug] Change np_state_write_string() to not be a pointer
Ton Voon
tonvoon at users.sourceforge.net
Mon Jun 21 14:08:27 CEST 2010
Module: nagiosplug
Branch: ton/state
Commit: 602896277c76298bcbc152312d915dec306eda27
Author: Ton Voon <ton.voon at opsera.com>
Date: Mon Jun 21 13:03:24 2010 +0100
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=6028962
Change np_state_write_string() to not be a pointer
---
lib/tests/test_utils.c | 10 +++++-----
lib/utils_base.c | 6 +++---
lib/utils_base.h | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index 6e04bfc..e90d4fb 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -355,7 +355,7 @@ main (int argc, char **argv)
unlink("var/generated");
temp_state_key->_filename="var/generated";
current_time=1234567890;
- np_state_write_string(¤t_time, "String to read");
+ np_state_write_string(current_time, "String to read");
ok(system("cmp var/generated var/statefile")==0, "Generated file same as expected");
@@ -365,20 +365,20 @@ main (int argc, char **argv)
unlink("var/generated_directory");
temp_state_key->_filename="var/generated_directory/statefile";
current_time=1234567890;
- np_state_write_string(¤t_time, "String to read");
+ np_state_write_string(current_time, "String to read");
ok(system("cmp var/generated_directory/statefile var/statefile")==0, "Have created directory");
/* This test to check cannot write to dir - can't automate yet */
/*
unlink("var/generated_bad_dir");
mkdir("var/generated_bad_dir", S_IRUSR);
- np_state_write_string(¤t_time, "String to read");
+ np_state_write_string(current_time, "String to read");
*/
temp_state_key->_filename="var/generated";
time(¤t_time);
- np_state_write_string(NULL, "String to read");
+ np_state_write_string(0, "String to read");
temp_state_data = np_state_read(temp_state_key);
/* Check time is set to current_time */
ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time");
@@ -388,7 +388,7 @@ main (int argc, char **argv)
/* Don't know how to automatically test this. Need to be able to redefine die and catch the error */
/*
temp_state_key->_filename="/dev/do/not/expect/to/be/able/to/write";
- np_state_write_string(NULL, "Bad file");
+ np_state_write_string(0, "Bad file");
*/
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 5eaf57b..e6b20c8 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -519,7 +519,7 @@ int _np_state_read_file(FILE *f) {
* two things writing to same key at same time.
* Will die with UNKNOWN if errors
*/
-void np_state_write_string(time_t *data_time, char *data_string) {
+void np_state_write_string(time_t data_time, char *data_string) {
FILE *fp;
char *temp_file=NULL;
int fd=0, result=0;
@@ -528,10 +528,10 @@ void np_state_write_string(time_t *data_time, char *data_string) {
char *directories=NULL;
char *p=NULL;
- if(data_time==NULL)
+ if(data_time==0)
time(¤t_time);
else
- current_time=*data_time;
+ current_time=data_time;
/* If file doesn't currently exist, create directories */
if(access(this_nagios_plugin->state->_filename,F_OK)!=0) {
diff --git a/lib/utils_base.h b/lib/utils_base.h
index 12576d7..8f2f664 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -95,7 +95,7 @@ char *np_extract_value(const char*, const char*, char);
void np_enable_state(char *, int);
state_data *np_state_read();
-void np_state_write_string(time_t *, char *);
+void np_state_write_string(time_t, char *);
void np_init(char *);
void np_cleanup();
More information about the Commits
mailing list