src.ctf.lttng-live: remove some goto error-handling
[babeltrace.git] / src / autodisc / autodisc.c
index 1a4f07dc39d537011f01428cb1d120d34dd02208..d171a33dba2edf790e3a443e630608a2add6c951 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #define BT_LOG_TAG "CLI-CFG-SRC-AUTO-DISC"
-#define BT_LOG_OUTPUT_LEVEL log_level
+#define BT_LOG_OUTPUT_LEVEL ((enum bt_log_level) log_level)
 #include "logging/log.h"
 
 #include <stdbool.h>
@@ -14,9 +14,9 @@
 #include "common/common.h"
 
 #define BT_AUTODISC_LOG_AND_APPEND(_lvl, _fmt, ...)                            \
-       do {                                                            \
-               BT_LOG_WRITE(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__);    \
-               (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \
+       do {                                                                    \
+               BT_LOG_WRITE_PRINTF(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__);     \
+               (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(       \
                        "Source auto-discovery", _fmt, ##__VA_ARGS__);          \
        } while (0)
 
@@ -347,7 +347,7 @@ auto_source_discovery_internal_status support_info_query_all_sources(
                const bt_component_class_source *source;
                const bt_plugin *plugin;
                const bt_value *group;
-               double weigth;
+               double weight;
        } winner = { NULL, NULL, NULL, 0 };
 
        if (interrupter && bt_interrupter_is_set(interrupter)) {
@@ -479,7 +479,7 @@ auto_source_discovery_internal_status support_info_query_all_sources(
                                        bt_plugin_get_name(plugin), bt_component_class_get_name(cc), input,
                                        input_type, weight, group_value ? bt_value_string_get(group_value) : "(none)");
 
-                               if (weight > winner.weigth) {
+                               if (weight > winner.weight) {
                                        winner.source = source_cc;
                                        winner.plugin = plugin;
 
@@ -487,7 +487,7 @@ auto_source_discovery_internal_status support_info_query_all_sources(
                                        winner.group = group_value;
                                        bt_value_get_ref(winner.group);
 
-                                       winner.weigth = weight;
+                                       winner.weight = weight;
                                }
                        } else if (query_status == BT_QUERY_EXECUTOR_QUERY_STATUS_ERROR) {
                                BT_AUTODISC_LOGE_APPEND_CAUSE("babeltrace.support-info query failed.");
@@ -516,7 +516,7 @@ auto_source_discovery_internal_status support_info_query_all_sources(
                group = winner.group ? bt_value_string_get(winner.group) : NULL;
 
                BT_LOGI("Input awarded: input=%s, type=%s, component-class-name=source.%s.%s, weight=%f, group=%s",
-                       input, input_type, plugin_name, source_name, winner.weigth, group ? group : "(none)");
+                       input, input_type, plugin_name, source_name, winner.weight, group ? group : "(none)");
 
                status = auto_source_discovery_add(auto_disc, plugin_name,
                        source_name, group, input, original_input_index, log_level);
@@ -579,6 +579,7 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
 {
        auto_source_discovery_internal_status status;
        GError *error = NULL;
+       GDir *dir = NULL;
 
        if (g_file_test(input->str, G_FILE_TEST_IS_REGULAR)) {
                /* It's a file. */
@@ -587,7 +588,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
                        component_class_restrict, log_level, auto_disc,
                        interrupter);
        } else if (g_file_test(input->str, G_FILE_TEST_IS_DIR)) {
-               GDir *dir;
                const gchar *dirent;
                gsize saved_input_len;
                int dir_status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH;
@@ -658,8 +658,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f
                } while (dirent);
 
                status = dir_status;
-
-               g_dir_close(dir);
        } else {
                BT_LOGD("Skipping %s, not a file or directory", input->str);
                status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH;
@@ -671,6 +669,9 @@ error:
        status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_ERROR;
 
 end:
+       if (dir) {
+               g_dir_close(dir);
+       }
 
        if (error) {
                g_error_free(error);
This page took 0.024092 seconds and 4 git commands to generate.