X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_notification.c;h=63e4f3154f15b97356a012560c2242cb06bb7db5;hb=71bbf854d3e6f8c6d6c3582527263bb01a3a7e04;hp=14fb5418addc659a5c429c03160ff3ef8e84871a;hpb=b758f3b7146f1497d93e1df64cbc0c14ae164768;p=collectd.git diff --git a/src/target_notification.c b/src/target_notification.c index 14fb5418..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,7 +192,7 @@ 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; @@ -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;