X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_notification.c;h=59d8c94f99323da6e80cf9b7ce2ed4412121d45b;hb=a5377cf935630082f2eac2e5f4a538844cc06c8d;hp=ceb454ecba7bb6e8579e27044468c876310437e0;hpb=e2b289ea039269b60edd459d2d514d3f82820e3a;p=collectd.git diff --git a/src/target_notification.c b/src/target_notification.c index ceb454ec..59d8c94f 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -25,6 +25,7 @@ **/ #include "collectd.h" + #include "common.h" #include "filter_chain.h" #include "utils_cache.h" @@ -126,13 +127,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; @@ -193,13 +193,13 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ notification_meta_t __attribute__((unused)) **meta, void **user_data) { tn_data_t *data; - notification_t n; + notification_t n = { 0 }; char temp[NOTIF_MAX_MSG_LEN]; gauge_t *rates; int rates_failed; - int i; + size_t i; if ((ds == NULL) || (vl == NULL) || (user_data == NULL)) return (-EINVAL); @@ -212,7 +212,6 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ } /* Initialize the structure. */ - memset (&n, 0, sizeof (n)); n.severity = data->severity; n.time = cdtime (); sstrncpy (n.message, data->message, sizeof (n.message)); @@ -277,9 +276,8 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ void module_register (void) { - target_proc_t tproc; + target_proc_t tproc = { 0 }; - memset (&tproc, 0, sizeof (tproc)); tproc.create = tn_create; tproc.destroy = tn_destroy; tproc.invoke = tn_invoke;