X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Folsrd.c;h=7838ebaaa2f90ed96164a19dfba6c37e4bc09591;hb=cd5c60931ef73c6c34be6dcf58538b069be17c58;hp=6d0576cf7bc7d26e39567646f40fa1ebd49262cc;hpb=633c3966f770e4d46651a2fe219a18d8a9907a9f;p=collectd.git diff --git a/src/olsrd.c b/src/olsrd.c index 6d0576cf..7838ebaa 100644 --- a/src/olsrd.c +++ b/src/olsrd.c @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -150,22 +149,18 @@ static size_t strtabsplit (char *string, char **fields, size_t size) /* {{{ */ static FILE *olsrd_connect (void) /* {{{ */ { - struct addrinfo ai_hints; struct addrinfo *ai_list, *ai_ptr; int ai_return; FILE *fh; - memset (&ai_hints, 0, sizeof (ai_hints)); - ai_hints.ai_flags = 0; -#ifdef AI_ADDRCONFIG - ai_hints.ai_flags |= AI_ADDRCONFIG; -#endif - ai_hints.ai_family = PF_UNSPEC; - ai_hints.ai_socktype = SOCK_STREAM; - ai_hints.ai_protocol = IPPROTO_TCP; + struct addrinfo ai_hints = { + .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG, + .ai_protocol = IPPROTO_TCP, + .ai_socktype = SOCK_STREAM + }; - ai_list = NULL; ai_return = getaddrinfo (olsrd_get_node (), olsrd_get_service (), &ai_hints, &ai_list); if (ai_return != 0) @@ -558,9 +553,8 @@ static int olsrd_cb_topology (int lineno, /* {{{ */ if (config_want_topology == OLSRD_WANT_DETAIL) { - char type_instance[DATA_MAX_NAME_LEN]; + char type_instance[DATA_MAX_NAME_LEN] = { 0 }; - memset (type_instance, 0, sizeof (type_instance)); ssnprintf (type_instance, sizeof (type_instance), "%s-%s-lq", fields[0], fields[1]); DEBUG ("olsrd plugin: type_instance = %s; lq = %g;", type_instance, lq); @@ -582,9 +576,8 @@ static int olsrd_cb_topology (int lineno, /* {{{ */ } else { - char type_instance[DATA_MAX_NAME_LEN]; + char type_instance[DATA_MAX_NAME_LEN] = { 0 }; - memset (type_instance, 0, sizeof (type_instance)); ssnprintf (type_instance, sizeof (type_instance), "%s-%s-nlq", fields[0], fields[1]); DEBUG ("olsrd plugin: type_instance = %s; nlq = %g;", type_instance, nlq); @@ -612,7 +605,7 @@ static int olsrd_read_table (FILE *fh, /* {{{ */ { /* An empty line ends the table. */ buffer_len = strchomp (buffer); - if (buffer_len <= 0) + if (buffer_len == 0) { (*callback) (lineno, /* fields_num = */ 0, /* fields = */ NULL); break; @@ -623,7 +616,7 @@ static int olsrd_read_table (FILE *fh, /* {{{ */ (*callback) (lineno, fields_num, fields); lineno++; } /* while (fgets) */ - + return (0); } /* }}} int olsrd_read_table */ @@ -664,9 +657,9 @@ static int olsrd_read (void) /* {{{ */ while (fgets (buffer, sizeof (buffer), fh) != NULL) { buffer_len = strchomp (buffer); - if (buffer_len <= 0) + if (buffer_len == 0) continue; - + if (strcmp ("Table: Links", buffer) == 0) olsrd_read_table (fh, olsrd_cb_links); else if (strcmp ("Table: Neighbors", buffer) == 0) @@ -691,7 +684,7 @@ static int olsrd_read (void) /* {{{ */ } /* while (fgets) */ fclose (fh); - + return (0); } /* }}} int olsrd_read */