X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fteamspeak2.c;h=1bd969bd9e158dcbf6d7bb92c5fd9e68f70ce599;hb=ec43e8a33bdcb116e75310c7bd9daae3bc912834;hp=40ca15e6828e3acaa0e8a9e326e445a3ba71451c;hpb=4103105fb43cd72294f165b2541540b3a8a99532;p=collectd.git diff --git a/src/teamspeak2.c b/src/teamspeak2.c index 40ca15e6..1bd969bd 100644 --- a/src/teamspeak2.c +++ b/src/teamspeak2.c @@ -121,14 +121,10 @@ static void tss2_submit_gauge (const char *plugin_instance, /* * Submits a gauge value to the collectd daemon */ - 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, "teamspeak2", sizeof (vl.plugin)); if (plugin_instance != NULL) @@ -150,15 +146,14 @@ static void tss2_submit_io (const char *plugin_instance, const char *type, /* * Submits the io rx/tx tuple to the collectd daemon */ - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - - values[0].derive = rx; - values[1].derive = tx; + value_t values[] = { + { .derive = rx }, + { .derive = tx }, + }; vl.values = values; - vl.values_len = 2; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + vl.values_len = STATIC_ARRAY_SIZE (values); sstrncpy (vl.plugin, "teamspeak2", sizeof (vl.plugin)); if (plugin_instance != NULL) @@ -200,7 +195,6 @@ static int tss2_get_socket (FILE **ret_read_fh, FILE **ret_write_fh) * if it's not already present */ struct addrinfo *ai_head; - struct addrinfo *ai_ptr; int sd = -1; int status; @@ -234,7 +228,7 @@ static int tss2_get_socket (FILE **ret_read_fh, FILE **ret_write_fh) } /* Try all given hosts until we can connect to one */ - for (ai_ptr = ai_head; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) + for (struct addrinfo *ai_ptr = ai_head; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) { /* Create socket */ sd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype, @@ -770,7 +764,6 @@ static int tss2_read (void) * Poll function which collects global and vserver information * and submits it to collectd */ - vserver_list_t *vserver; int success = 0; int status; @@ -786,7 +779,7 @@ static int tss2_read (void) } /* Handle vservers */ - for (vserver = server_list; vserver != NULL; vserver = vserver->next) + for (vserver_list_t *vserver = server_list; vserver != NULL; vserver = vserver->next) { status = tss2_read_vserver (vserver); if (status == 0)