From 68b76e9e32d172936e7f01d6ac0cd5e4d49f8d46 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 10 Mar 2015 15:34:10 +0100 Subject: [PATCH] write_tsdb plugin: Fix name generation even more. There were more cases in which "type" or "type_instance" were omitted. Fixes: #945 --- src/write_tsdb.c | 57 +++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/write_tsdb.c b/src/write_tsdb.c index bfac1a14..9008a67b 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -366,37 +366,40 @@ static int wt_format_name(char *ret, int ret_len, if (ds_name != NULL) { if (vl->plugin_instance[0] == '\0') { if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s", - prefix, vl->plugin, vl->type, - ds_name); + ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, + vl->type, ds_name); } else { - ssnprintf(ret, ret_len, "%s%s.%s.%s", - prefix, vl->plugin, vl->type_instance, - ds_name); + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, + vl->type, vl->type_instance, ds_name); + } + } else { /* vl->plugin_instance != "" */ + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, + vl->plugin_instance, vl->type, ds_name); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s.%s", prefix, + vl->plugin, vl->plugin_instance, vl->type, + vl->type_instance, ds_name); } - } else if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, vl->type, - ds_name); - } else { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, vl->type, - vl->type_instance, ds_name); } - } else if (vl->plugin_instance[0] == '\0') { - if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, vl->type); - } else { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, vl->type_instance); + } else { /* ds_name == NULL */ + if (vl->plugin_instance[0] == '\0') { + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, + vl->type); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, + vl->type_instance, vl->type); + } + } else { /* vl->plugin_instance != "" */ + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, + vl->plugin_instance, vl->type); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, + vl->plugin_instance, vl->type, vl->type_instance); + } } - } else if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, vl->type); - } else { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, vl->type, vl->type_instance); } sfree(temp); -- 2.30.2