X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_notification.c;h=63e4f3154f15b97356a012560c2242cb06bb7db5;hb=cd5c60931ef73c6c34be6dcf58538b069be17c58;hp=ceb454ecba7bb6e8579e27044468c876310437e0;hpb=3307054b6ab46b51fdda4f528e72d119e9de3071;p=collectd.git diff --git a/src/target_notification.c b/src/target_notification.c index ceb454ec..63e4f315 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; @@ -193,13 +192,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 +211,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 +275,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;