*/
#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>
#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)
{
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. */
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;
dir = g_dir_open(input->str, 0, &error);
if (!dir) {
- const char *fmt = "Failed to open directory %s: %s";
- BT_LOGW(fmt, input->str, error->message);
+#define BT_FMT "Failed to open directory %s: %s"
+ BT_LOGW(BT_FMT, input->str, error->message);
if (error->code == G_FILE_ERROR_ACCES) {
/* This is not a fatal error, we just skip it. */
status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH;
goto end;
} else {
- BT_AUTODISC_LOGE_APPEND_CAUSE(fmt, input->str,
+ BT_AUTODISC_LOGE_APPEND_CAUSE(BT_FMT, input->str,
error->message);
goto error;
}
+#undef BT_FMT
}
saved_input_len = input->len;
} 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;
status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_ERROR;
end:
+ if (dir) {
+ g_dir_close(dir);
+ }
if (error) {
g_error_free(error);