X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=712c24fa5b153272b5be422b0ef2ae7fcdf12eb8;hb=f14bb45d570e0b34bdd3a2a0cadfe414c3dfda40;hp=3d6039c47d519d7b3f8e6d217c7d65882c7b74bc;hpb=1e34eeecc5939118e644be5337612a0326781f8e;p=collectd.git diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 3d6039c4..712c24fa 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -136,14 +136,14 @@ static int filter_ds (size_t *values_num, new_values = (gauge_t *)calloc (match_ds_num_g, sizeof (*new_values)); if (new_values == NULL) { - fprintf (stderr, "malloc failed: %s\n", strerror (errno)); + fprintf (stderr, "calloc failed: %s\n", strerror (errno)); return (RET_UNKNOWN); } new_names = (char **)calloc (match_ds_num_g, sizeof (*new_names)); if (new_names == NULL) { - fprintf (stderr, "malloc failed: %s\n", strerror (errno)); + fprintf (stderr, "calloc failed: %s\n", strerror (errno)); free (new_values); return (RET_UNKNOWN); } @@ -245,6 +245,7 @@ static int match_range (range_t *range, double value) return (((ret - range->invert) == 0) ? 0 : 1); } /* int match_range */ +__attribute__((noreturn)) static void usage (const char *name) { fprintf (stderr, "Usage: %s <-s socket> <-n value_spec> <-H hostname> [options]\n" @@ -308,8 +309,7 @@ static int do_listval (lcc_connection_t *connection) if ((hostname == NULL) || strcasecmp (hostname, ret_ident[i].host)) { - if (hostname != NULL) - free (hostname); + free (hostname); hostname = strdup (ret_ident[i].host); printf ("Host: %s\n", hostname); } @@ -323,6 +323,8 @@ static int do_listval (lcc_connection_t *connection) printf ("ERROR: listval: Failed to convert returned " "identifier to a string: %s\n", lcc_strerror (connection)); + free (hostname); + hostname = NULL; continue; } @@ -330,8 +332,8 @@ static int do_listval (lcc_connection_t *connection) printf ("\t%s\n", id + 1); } - if (ret_ident != NULL) - free (ret_ident); + free (ret_ident); + free (hostname); return (RET_OKAY); } /* int do_listval */