#include <errno.h>
#include <math.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils_heap.h"
-#include "libcollectdclient/collectd/client.h"
-#include "libcollectdclient/collectd/network.h"
+#include "collectd/client.h"
+#include "collectd/network.h"
#define DEF_NUM_HOSTS 1000
#define DEF_NUM_PLUGINS 20
static lcc_network_t *net;
-static c_heap_t *values_heap = NULL;
+static c_heap_t *values_heap;
static struct sigaction sigint_action;
static struct sigaction sigterm_action;
-static _Bool loop = 1;
+static bool loop = true;
__attribute__((noreturn)) static void exit_usage(int exit_status) /* {{{ */
{
exit(exit_status);
} /* }}} void exit_usage */
-static void signal_handler(int signal) /* {{{ */
+static void signal_handler(int __attribute__((unused)) signal) /* {{{ */
{
- loop = 0;
+ loop = false;
} /* }}} void signal_handler */
#if HAVE_CLOCK_GETTIME
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
perror("clock_gettime");
- return ((double)ts.tv_sec) + (((double)ts.tv_nsec) / 1e9);
+ return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
} /* }}} double dtime */
#else
/* Work around for Mac OS X which doesn't have clock_gettime(2). *sigh* */
if (gettimeofday(&tv, /* timezone = */ NULL) != 0)
perror("gettimeofday");
- return ((double)tv.tv_sec) + (((double)tv.tv_usec) / 1e6);
+ return (double)tv.tv_sec + ((double)tv.tv_usec) / 1e6;
} /* }}} double dtime */
#endif
const lcc_value_list_t *vl1 = v1;
if (vl0->time < vl1->time)
- return (-1);
+ return -1;
else if (vl0->time > vl1->time)
- return (1);
+ return 1;
else
- return (0);
+ return 0;
} /* }}} int compare_time */
static int get_boundet_random(int min, int max) /* {{{ */
int range;
if (min >= max)
- return (-1);
+ return -1;
if (min == (max - 1))
- return (min);
+ return min;
range = max - min;
- return (min + ((int)(((double)range) * ((double)random()) /
- (((double)RAND_MAX) + 1.0))));
+ return min + ((int)(((double)range) * ((double)random()) /
+ (((double)RAND_MAX) + 1.0)));
} /* }}} int get_boundet_random */
static lcc_value_list_t *create_value_list(void) /* {{{ */
vl = calloc(1, sizeof(*vl));
if (vl == NULL) {
fprintf(stderr, "calloc failed.\n");
- return (NULL);
+ return NULL;
}
vl->values = calloc(/* nmemb = */ 1, sizeof(*vl->values));
if (vl->values == NULL) {
fprintf(stderr, "calloc failed.\n");
free(vl);
- return (NULL);
+ return NULL;
}
vl->values_types = calloc(/* nmemb = */ 1, sizeof(*vl->values_types));
fprintf(stderr, "calloc failed.\n");
free(vl->values);
free(vl);
- return (NULL);
+ return NULL;
}
vl->values_len = 1;
snprintf(vl->identifier.type_instance, sizeof(vl->identifier.type_instance),
"ti%li", random());
- return (vl);
+ return vl;
} /* }}} int create_value_list */
static void destroy_value_list(lcc_value_list_t *vl) /* {{{ */
vl->time += vl->interval;
- return (0);
+ return 0;
} /* }}} int send_value */
static int get_integer_opt(const char *str, int *ret_value) /* {{{ */
}
*ret_value = tmp;
- return (0);
+ return 0;
} /* }}} int get_integer_opt */
static int get_double_opt(const char *str, double *ret_value) /* {{{ */
}
*ret_value = tmp;
- return (0);
+ return 0;
} /* }}} int get_double_opt */
static int read_options(int argc, char **argv) /* {{{ */
} /* switch (opt) */
} /* while (getopt) */
- return (0);
+ return 0;
} /* }}} int read_options */
int main(int argc, char **argv) /* {{{ */