Fix unreachable clause where both tmp_plugin and tmp_plugin_instance are non-empty.
authorLing Huang <lingshi@google.com>
Wed, 27 Nov 2019 21:32:39 +0000 (16:32 -0500)
committerLing Huang <lingshi@google.com>
Tue, 7 Jan 2020 03:33:55 +0000 (22:33 -0500)
src/aggregation.c

index 2c8ef88..d7b8e72 100644 (file)
@@ -194,17 +194,21 @@ static int agg_instance_create_name(agg_instance_t *inst, /* {{{ */
       sstrncpy(tmp_plugin_instance, agg->ident.plugin_instance,
                sizeof(tmp_plugin_instance));
 
+    // Both tmp_plugin and tmp_plugin_instance are empty.
     if ((strcmp("", tmp_plugin) == 0) && (strcmp("", tmp_plugin_instance) == 0))
       sstrncpy(inst->ident.plugin_instance, AGG_FUNC_PLACEHOLDER,
                sizeof(inst->ident.plugin_instance));
-    else if (strcmp("", tmp_plugin) != 0)
+    // tmp_plugin is non-empty and tmp_plugin_instance is empty.
+    else if (strcmp("", tmp_plugin_instance) == 0)
       ssnprintf(inst->ident.plugin_instance,
                 sizeof(inst->ident.plugin_instance), "%s-%s", tmp_plugin,
                 AGG_FUNC_PLACEHOLDER);
-    else if (strcmp("", tmp_plugin_instance) != 0)
+    // tmp_plugin is empty and tmp_plugin_instance is non-empty.
+    else if (strcmp("", tmp_plugin) == 0)
       ssnprintf(inst->ident.plugin_instance,
                 sizeof(inst->ident.plugin_instance), "%s-%s",
                 tmp_plugin_instance, AGG_FUNC_PLACEHOLDER);
+    // Both tmp_plugin and tmp_plugin_instance are non-empty.
     else
       ssnprintf(inst->ident.plugin_instance,
                 sizeof(inst->ident.plugin_instance), "%s-%s-%s", tmp_plugin,