summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 6d6954e..90a4aaa 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -33,12 +33,12 @@
33#include <unistd.h> 33#include <unistd.h>
34#include <sys/types.h> 34#include <sys/types.h>
35 35
36#define np_free(ptr) \ 36#define np_free(ptr) \
37 { \ 37 { \
38 if (ptr) { \ 38 if (ptr) { \
39 free(ptr); \ 39 free(ptr); \
40 ptr = NULL; \ 40 ptr = NULL; \
41 } \ 41 } \
42 } 42 }
43 43
44monitoring_plugin *this_monitoring_plugin = NULL; 44monitoring_plugin *this_monitoring_plugin = NULL;
@@ -511,7 +511,8 @@ void np_enable_state(char *keyname, int expected_data_version) {
511 this_state->state_data = NULL; 511 this_state->state_data = NULL;
512 512
513 /* Calculate filename */ 513 /* Calculate filename */
514 ret = asprintf(&temp_filename, "%s/%lu/%s/%s", _np_state_calculate_location_prefix(), (unsigned long)geteuid(), this_monitoring_plugin->plugin_name, this_state->name); 514 ret = asprintf(&temp_filename, "%s/%lu/%s/%s", _np_state_calculate_location_prefix(), (unsigned long)geteuid(),
515 this_monitoring_plugin->plugin_name, this_state->name);
515 if (ret < 0) 516 if (ret < 0)
516 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno)); 517 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno));
517 518
@@ -568,7 +569,13 @@ bool _np_state_read_file(FILE *f) {
568 int i; 569 int i;
569 int failure = 0; 570 int failure = 0;
570 time_t current_time, data_time; 571 time_t current_time, data_time;
571 enum { STATE_FILE_VERSION, STATE_DATA_VERSION, STATE_DATA_TIME, STATE_DATA_TEXT, STATE_DATA_END } expected = STATE_FILE_VERSION; 572 enum {
573 STATE_FILE_VERSION,
574 STATE_DATA_VERSION,
575 STATE_DATA_TIME,
576 STATE_DATA_TEXT,
577 STATE_DATA_END
578 } expected = STATE_FILE_VERSION;
572 579
573 time(&current_time); 580 time(&current_time);
574 581