From: Florian Forster Date: Wed, 1 Jul 2009 09:18:52 +0000 (+0200) Subject: src/plugin.c: Introduce the `DS_TYPE_TO_STRING' macro. X-Git-Tag: collectd-4.8.0~97 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4681a2490fbb74b37bb6f516c4c96c76b0715f7c;p=collectd.git src/plugin.c: Introduce the `DS_TYPE_TO_STRING' macro. --- diff --git a/src/plugin.h b/src/plugin.h index 0ccb198c..b35fcf18 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -33,6 +33,13 @@ #define DS_TYPE_DERIVE 2 #define DS_TYPE_ABSOLUTE 3 +#define DS_TYPE_TO_STRING(t) (t == DS_TYPE_COUNTER) ? "counter" : \ + (t == DS_TYPE_GAUGE) ? "gauge" : \ + (t == DS_TYPE_DERIVE) ? "derive" : \ + (t == DS_TYPE_ABSOLUTE) ? "absolute" : \ + "unknown" + + #ifndef LOG_ERR # define LOG_ERR 3 #endif diff --git a/src/utils_db_query.c b/src/utils_db_query.c index 9a211b4d..5f892a40 100644 --- a/src/utils_db_query.c +++ b/src/utils_db_query.c @@ -211,7 +211,7 @@ static int udb_legacy_result_handle_result (udb_result_t *r, /* {{{ */ { ERROR ("db query utils: udb_legacy_result_handle_result: " "Parsing `%s' as %s failed.", value_str, - (r->ds->ds[0].type == DS_TYPE_COUNTER) ? "counter" : "gauge"); + DS_TYPE_TO_STRING (r->ds->ds[0].type)); errno = EINVAL; return (-1); } @@ -367,8 +367,7 @@ static int udb_result_submit (udb_result_t *r, udb_query_t *q) /* {{{ */ if (0 != parse_value (value_str, &vl.values[i], r->ds->ds[i].type)) { ERROR ("db query utils: udb_result_submit: Parsing `%s' as %s failed.", - value_str, - (r->ds->ds[i].type == DS_TYPE_COUNTER) ? "counter" : "gauge"); + value_str, DS_TYPE_TO_STRING (r->ds->ds[i].type)); errno = EINVAL; return (-1); }