X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Folsrd.c;h=1ac1d42610d92ae3f145d2fca94ce0e0305a6da5;hp=c58586d8c8d1c19513e9ef41ea44d6ac72617e9e;hb=7111bb6df7628edce3a8e538b386fbe27633a191;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f diff --git a/src/olsrd.c b/src/olsrd.c index c58586d8..1ac1d426 100644 --- a/src/olsrd.c +++ b/src/olsrd.c @@ -54,15 +54,15 @@ static int config_want_topology = OLSRD_WANT_SUMMARY; static const char *olsrd_get_node(void) /* {{{ */ { if (config_node != NULL) - return (config_node); - return (OLSRD_DEFAULT_NODE); + return config_node; + return OLSRD_DEFAULT_NODE; } /* }}} const char *olsrd_get_node */ static const char *olsrd_get_service(void) /* {{{ */ { if (config_service != NULL) - return (config_service); - return (OLSRD_DEFAULT_SERVICE); + return config_service; + return OLSRD_DEFAULT_SERVICE; } /* }}} const char *olsrd_get_service */ static void olsrd_set_node(const char *node) /* {{{ */ @@ -114,7 +114,7 @@ static size_t strchomp(char *buffer) /* {{{ */ buffer[buffer_len] = 0; } - return (buffer_len); + return buffer_len; } /* }}} size_t strchomp */ static size_t strtabsplit(char *string, char **fields, size_t size) /* {{{ */ @@ -134,7 +134,7 @@ static size_t strtabsplit(char *string, char **fields, size_t size) /* {{{ */ break; } - return (i); + return i; } /* }}} size_t strtabsplit */ static FILE *olsrd_connect(void) /* {{{ */ @@ -154,7 +154,7 @@ static FILE *olsrd_connect(void) /* {{{ */ if (ai_return != 0) { ERROR("olsrd plugin: getaddrinfo (%s, %s) failed: %s", olsrd_get_node(), olsrd_get_service(), gai_strerror(ai_return)); - return (NULL); + return NULL; } fh = NULL; @@ -191,21 +191,17 @@ static FILE *olsrd_connect(void) /* {{{ */ freeaddrinfo(ai_list); - return (fh); + return fh; } /* }}} FILE *olsrd_connect */ __attribute__((nonnull(2))) static void olsrd_submit(const char *plugin_instance, /* {{{ */ const char *type, const char *type_instance, gauge_t value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = value; - - vl.values = values; + vl.values = &(value_t){.gauge = value}; vl.values_len = 1; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, "olsrd", sizeof(vl.plugin)); if (plugin_instance != NULL) sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); @@ -218,7 +214,7 @@ olsrd_submit(const char *plugin_instance, /* {{{ */ static int olsrd_cb_ignore(int lineno, /* {{{ */ size_t fields_num, char **fields) { - return (0); + return 0; } /* }}} int olsrd_cb_ignore */ static int olsrd_cb_links(int lineno, /* {{{ */ @@ -243,7 +239,7 @@ static int olsrd_cb_links(int lineno, /* {{{ */ char *endptr; if (config_want_links == OLSRD_WANT_NOT) - return (0); + return 0; /* Special handling of the first line. */ if (lineno <= 0) { @@ -253,7 +249,7 @@ static int olsrd_cb_links(int lineno, /* {{{ */ nlq_sum = 0.0; nlq_num = 0; - return (0); + return 0; } /* Special handling of the last line. */ @@ -276,11 +272,11 @@ static int olsrd_cb_links(int lineno, /* {{{ */ olsrd_submit(/* p.-inst = */ "links", /* type = */ "signal_quality", "average-nlq", nlq); - return (0); + return 0; } if (fields_num != 6) - return (-1); + return -1; links_num++; @@ -298,8 +294,8 @@ static int olsrd_cb_links(int lineno, /* {{{ */ if (config_want_links == OLSRD_WANT_DETAIL) { char type_instance[DATA_MAX_NAME_LEN]; - ssnprintf(type_instance, sizeof(type_instance), "%s-%s-lq", fields[0], - fields[1]); + snprintf(type_instance, sizeof(type_instance), "%s-%s-lq", fields[0], + fields[1]); DEBUG("olsrd plugin: links: type_instance = %s; lq = %g;", type_instance, lq); @@ -322,8 +318,8 @@ static int olsrd_cb_links(int lineno, /* {{{ */ if (config_want_links == OLSRD_WANT_DETAIL) { char type_instance[DATA_MAX_NAME_LEN]; - ssnprintf(type_instance, sizeof(type_instance), "%s-%s-rx", fields[0], - fields[1]); + snprintf(type_instance, sizeof(type_instance), "%s-%s-rx", fields[0], + fields[1]); DEBUG("olsrd plugin: links: type_instance = %s; nlq = %g;", type_instance, lq); @@ -332,7 +328,7 @@ static int olsrd_cb_links(int lineno, /* {{{ */ } } - return (0); + return 0; } /* }}} int olsrd_cb_links */ static int olsrd_cb_routes(int lineno, /* {{{ */ @@ -355,7 +351,7 @@ static int olsrd_cb_routes(int lineno, /* {{{ */ char *endptr; if (config_want_routes == OLSRD_WANT_NOT) - return (0); + return 0; /* Special handling of the first line */ if (lineno <= 0) { @@ -365,7 +361,7 @@ static int olsrd_cb_routes(int lineno, /* {{{ */ etx_sum = 0.0; etx_num = 0; - return (0); + return 0; } /* Special handling after the last line */ @@ -390,11 +386,11 @@ static int olsrd_cb_routes(int lineno, /* {{{ */ olsrd_submit(/* p.-inst = */ "routes", /* type = */ "route_etx", "average", etx); - return (0); + return 0; } if (fields_num != 5) - return (-1); + return -1; routes_num++; @@ -433,7 +429,7 @@ static int olsrd_cb_routes(int lineno, /* {{{ */ } } - return (0); + return 0; } /* }}} int olsrd_cb_routes */ static int olsrd_cb_topology(int lineno, /* {{{ */ @@ -454,7 +450,7 @@ static int olsrd_cb_topology(int lineno, /* {{{ */ char *endptr; if (config_want_topology == OLSRD_WANT_NOT) - return (0); + return 0; /* Special handling of the first line */ if (lineno <= 0) { @@ -462,7 +458,7 @@ static int olsrd_cb_topology(int lineno, /* {{{ */ lq_num = 0; links_num = 0; - return (0); + return 0; } /* Special handling after the last line */ @@ -478,11 +474,11 @@ static int olsrd_cb_topology(int lineno, /* {{{ */ olsrd_submit(/* p.-inst = */ "topology", /* type = */ "signal_quality", /* t.-inst = */ "average", lq); - return (0); + return 0; } if (fields_num != 5) - return (-1); + return -1; links_num++; @@ -500,8 +496,8 @@ static int olsrd_cb_topology(int lineno, /* {{{ */ if (config_want_topology == OLSRD_WANT_DETAIL) { char type_instance[DATA_MAX_NAME_LEN] = {0}; - ssnprintf(type_instance, sizeof(type_instance), "%s-%s-lq", fields[0], - fields[1]); + snprintf(type_instance, sizeof(type_instance), "%s-%s-lq", fields[0], + fields[1]); DEBUG("olsrd plugin: type_instance = %s; lq = %g;", type_instance, lq); olsrd_submit(/* p.-inst = */ "topology", /* type = */ "signal_quality", type_instance, lq); @@ -519,15 +515,15 @@ static int olsrd_cb_topology(int lineno, /* {{{ */ } else { char type_instance[DATA_MAX_NAME_LEN] = {0}; - ssnprintf(type_instance, sizeof(type_instance), "%s-%s-nlq", fields[0], - fields[1]); + snprintf(type_instance, sizeof(type_instance), "%s-%s-nlq", fields[0], + fields[1]); DEBUG("olsrd plugin: type_instance = %s; nlq = %g;", type_instance, nlq); olsrd_submit(/* p.-inst = */ "topology", /* type = */ "signal_quality", type_instance, nlq); } } - return (0); + return 0; } /* }}} int olsrd_cb_topology */ static int olsrd_read_table(FILE *fh, /* {{{ */ @@ -556,7 +552,7 @@ static int olsrd_read_table(FILE *fh, /* {{{ */ lineno++; } /* while (fgets) */ - return (0); + return 0; } /* }}} int olsrd_read_table */ static int olsrd_config(const char *key, const char *value) /* {{{ */ @@ -573,10 +569,10 @@ static int olsrd_config(const char *key, const char *value) /* {{{ */ olsrd_set_detail(&config_want_topology, value, key); else { ERROR("olsrd plugin: Unknown configuration option given: %s", key); - return (-1); + return -1; } - return (0); + return 0; } /* }}} int olsrd_config */ static int olsrd_read(void) /* {{{ */ @@ -587,7 +583,7 @@ static int olsrd_read(void) /* {{{ */ fh = olsrd_connect(); if (fh == NULL) - return (-1); + return -1; fputs("\r\n", fh); fflush(fh); @@ -619,7 +615,7 @@ static int olsrd_read(void) /* {{{ */ fclose(fh); - return (0); + return 0; } /* }}} int olsrd_read */ static int olsrd_shutdown(void) /* {{{ */ @@ -627,7 +623,7 @@ static int olsrd_shutdown(void) /* {{{ */ sfree(config_node); sfree(config_service); - return (0); + return 0; } /* }}} int olsrd_shutdown */ void module_register(void) { @@ -635,5 +631,3 @@ void module_register(void) { plugin_register_read("olsrd", olsrd_read); plugin_register_shutdown("olsrd", olsrd_shutdown); } /* void module_register */ - -/* vim: set sw=2 sts=2 et fdm=marker : */