From: Florian Forster Date: Sat, 3 Jul 2010 12:02:15 +0000 (+0200) Subject: src/utils_cache.c: Resolve macros that are used only once. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f3c138db5d174db6bcb7ceb0ff38973ebc0dbe99;p=collectd.git src/utils_cache.c: Resolve macros that are used only once. --- diff --git a/src/utils_cache.c b/src/utils_cache.c index 3f7911fd..37b8ae8f 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -211,26 +211,19 @@ static int uc_send_notification (const char *name) { char msg[NOTIF_MAX_MSG_LEN]; char temp[NOTIF_MAX_MSG_LEN]; + char missing[NOTIF_MAX_MSG_LEN]; sstrncpy (msg, th.missing_message, sizeof (msg)); - (void) ut_build_message (msg, NOTIF_MAX_MSG_LEN, th.missing_message, - &ds, 0, &vl, ce->values_gauge, + ut_build_message (msg, sizeof (msg), th.missing_message, + &ds, /* ds index = */ 0, &vl, ce->values_gauge, &n, &th); -#define REPLACE_FIELD(t,v) \ - if (subst_string (temp, sizeof (temp), msg, t, v) != NULL) \ - sstrncpy (msg, temp, sizeof (msg)); + ssnprintf (missing, sizeof(missing), "%li", + (long int) (n.time - ce->last_update)); + if (subst_string (temp, sizeof (temp), msg, "%{missing}", missing) != NULL) + sstrncpy (msg, temp, sizeof (msg)); - char itoa_temp[NOTIF_MAX_MSG_LEN]; -#define ITOA(string,i) \ - memset(string,0x00,sizeof(string)); \ - snprintf(string, sizeof(string), "%i", i); - - ITOA(itoa_temp, (int)(n.time - ce->last_update)) - REPLACE_FIELD("%{missing}", itoa_temp) - - (void) ssnprintf (n.message, sizeof (n.message), - "%s", msg); + sstrncpy (n.message, msg, sizeof (n.message)); } else {