X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fchrony.c;h=012fd9a9bcb28bb02a37ff9845a5aabb712b5342;hb=240a0b30cd9a478589ed00465bc081f810da05a9;hp=4554f4990e36183e6e45eab3ce2b6cf462dc7672;hpb=5eb1fef6de7e0c8fb99e3d85063d96d7cc785f9b;p=collectd.git diff --git a/src/chrony.c b/src/chrony.c index 4554f499..012fd9a9 100644 --- a/src/chrony.c +++ b/src/chrony.c @@ -105,8 +105,8 @@ typedef enum } eDaemonReplies; -#if defined(__GNUC__) -# /* GNU gcc extension to enforce struct packing. */ +#if defined(__GNUC__) || defined (__SUNPRO_C) || defined(lint) +# /* extension to enforce struct packing. */ # define ATTRIB_PACKED __attribute__((packed)) #else # error Not defining packed attribute (unknown compiler) @@ -389,7 +389,7 @@ niptoha(const tChrony_IPAddr * addr, char *p_buf, size_t p_buf_size) static int -chrony_set_timeout() +chrony_set_timeout(void) { /* Set the socket's timeout to g_chrony_timeout; a value of 0 signals infinite timeout */ /* Returns 0 on success, !0 on error (check errno) */ @@ -409,7 +409,7 @@ chrony_set_timeout() static int -chrony_connect() +chrony_connect(void) { /* Connects to the chrony daemon */ /* Returns 0 on success, !0 on error (check errno) */ @@ -674,7 +674,7 @@ ntohf(tFloat p_float) static void -chrony_push_data(char *p_type, char *p_type_inst, double p_value) +chrony_push_data(const char *p_type, const char *p_type_inst, double p_value) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; @@ -705,7 +705,7 @@ chrony_push_data(char *p_type, char *p_type_inst, double p_value) static void -chrony_push_data_valid(char *p_type, char *p_type_inst, const int p_is_valid, +chrony_push_data_valid(const char *p_type, const char *p_type_inst, const int p_is_valid, double p_value) { /* Push real value if p_is_valid is true, push NAN if p_is_valid is not true (idea from ntp plugin) */ @@ -717,13 +717,15 @@ chrony_push_data_valid(char *p_type, char *p_type_inst, const int p_is_valid, static int -chrony_init_seq() +chrony_init_seq(void) { /* Initialize the sequence number generator from /dev/urandom */ /* Fallbacks: /dev/random and time(NULL) */ + int fh; + /* Try urandom */ - int fh = open(URAND_DEVICE_PATH, O_RDONLY); + fh = open(URAND_DEVICE_PATH, O_RDONLY); if (fh >= 0) { ssize_t rc = read(fh, &g_chrony_rand, sizeof(g_chrony_rand)); @@ -742,7 +744,7 @@ chrony_init_seq() if (errno == ENOENT) { /* URAND_DEVICE_PATH device not found. Try RAND_DEVICE_PATH as fall-back */ - int fh = open(RAND_DEVICE_PATH, O_RDONLY); + fh = open(RAND_DEVICE_PATH, O_RDONLY); if (fh >= 0) { ssize_t rc = read(fh, &g_chrony_rand, sizeof(g_chrony_rand)); @@ -831,7 +833,7 @@ chrony_config(const char *p_key, const char *p_value) static int -chrony_request_daemon_stats() +chrony_request_daemon_stats(void) { /* Perform Tracking request */ int rc; @@ -1049,7 +1051,7 @@ chrony_request_source_stats(int p_src_idx, const int *p_is_reachable) static int -chrony_read() +chrony_read(void) { /* collectd read callback: Perform data acquisition */ int rc; @@ -1092,7 +1094,7 @@ chrony_read() static int -chrony_shutdown() +chrony_shutdown(void) { /* Collectd shutdown callback: Free mem */ if (g_chrony_is_connected != 0)