X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftarget_notification.c;h=55b72ac1acf330f15ea8899aa8181ca134a64bd3;hb=d67b510b1ec7c17b6e1f65e40b8d8fdb2f33c857;hp=5eaa427528183e2ac70ad47ec647ffb21034eb9f;hpb=9679723b9f177055ef93d0b1bbb420cca7ac6ea4;p=collectd.git diff --git a/src/target_notification.c b/src/target_notification.c index 5eaa4275..55b72ac1 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -126,13 +126,12 @@ static int tn_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ int status; int i; - data = (tn_data_t *) malloc (sizeof (*data)); + data = calloc (1, sizeof (*data)); if (data == NULL) { - ERROR ("tn_create: malloc failed."); + ERROR ("tn_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->message = NULL; data->severity = 0; @@ -181,7 +180,7 @@ static int tn_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ if (status != 0) { - tn_destroy ((void *) data); + tn_destroy ((void *) &data); return (status); } @@ -199,7 +198,7 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ gauge_t *rates; int rates_failed; - int i; + size_t i; if ((ds == NULL) || (vl == NULL) || (user_data == NULL)) return (-EINVAL); @@ -256,12 +255,12 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ /* If this is a gauge value, use the current value. */ if (ds->ds[i].type == DS_TYPE_GAUGE) ssnprintf (value_str, sizeof (value_str), - "%g", (double) vl->values[i].gauge); + GAUGE_FORMAT, (double) vl->values[i].gauge); /* If it's a counter, try to use the current rate. This may fail, if the * value has been renamed. */ else if (rates != NULL) ssnprintf (value_str, sizeof (value_str), - "%g", (double) rates[i]); + GAUGE_FORMAT, (double) rates[i]); /* Since we don't know any better, use the string `unknown'. */ else sstrncpy (value_str, "unknown", sizeof (value_str));