From 25a0e3beb4a73e59344dd8dc5eab8744debf0213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 29 Sep 2021 13:22:41 +0200 Subject: [PATCH] spa: support: do not include C source file Previously, `log-patterns.c` was included in two other source files (`journal.c` and `logger.c`). It was also specified in the sources list for the libspa-support library, which resulted in the unnecessary independent compilation of the file, generating "defined but not used" warnings. Extract the function definitions into `log-patterns.h` and use that in `journal.c` and `logger.c`, and remove the inclusion of `log-patterns.c` from both. --- spa/plugins/support/journal.c | 4 ++-- spa/plugins/support/log-patterns.c | 8 +++++--- spa/plugins/support/log-patterns.h | 13 +++++++++++++ spa/plugins/support/logger.c | 4 ++-- spa/plugins/support/meson.build | 5 ++++- 5 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 spa/plugins/support/log-patterns.h diff --git a/spa/plugins/support/journal.c b/spa/plugins/support/journal.c index ed4fd183f..e0e58ebeb 100644 --- a/spa/plugins/support/journal.c +++ b/spa/plugins/support/journal.c @@ -39,12 +39,12 @@ #include +#include "log-patterns.h" + #define NAME "journal" #define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_INFO -#include "log-patterns.c" - struct impl { struct spa_handle handle; struct spa_log log; diff --git a/spa/plugins/support/log-patterns.c b/spa/plugins/support/log-patterns.c index c9d323a34..eb71eeb47 100644 --- a/spa/plugins/support/log-patterns.c +++ b/spa/plugins/support/log-patterns.c @@ -29,13 +29,15 @@ #include #include +#include "log-patterns.h" + struct support_log_pattern { struct spa_list link; enum spa_log_level level; char pattern[]; }; -static void +void support_log_topic_init(struct spa_list *patterns, enum spa_log_level default_level, struct spa_log_topic *t) { @@ -53,7 +55,7 @@ support_log_topic_init(struct spa_list *patterns, enum spa_log_level default_lev t->level = level; } -static int +int support_log_parse_patterns(struct spa_list *patterns, const char *jsonstr) { struct spa_json iter, array, elem; @@ -94,7 +96,7 @@ support_log_parse_patterns(struct spa_list *patterns, const char *jsonstr) return res; } -static void +void support_log_free_patterns(struct spa_list *patterns) { struct support_log_pattern *p, *tmp; diff --git a/spa/plugins/support/log-patterns.h b/spa/plugins/support/log-patterns.h new file mode 100644 index 000000000..a10b44523 --- /dev/null +++ b/spa/plugins/support/log-patterns.h @@ -0,0 +1,13 @@ +#ifndef LOG_PATTERNS_H +#define LOG_PATTERNS_H + +#include + +struct spa_list; + +void support_log_topic_init(struct spa_list *patterns, enum spa_log_level default_level, + struct spa_log_topic *t); +int support_log_parse_patterns(struct spa_list *patterns, const char *jsonstr); +void support_log_free_patterns(struct spa_list *patterns); + +#endif /* LOG_PATTERNS_H */ diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 83b754eea..4390ecc5a 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -40,6 +40,8 @@ #include #include +#include "log-patterns.h" + #ifdef __FreeBSD__ #define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC #endif @@ -50,8 +52,6 @@ #define TRACE_BUFFER (16*1024) -#include "log-patterns.c" - struct impl { struct spa_handle handle; struct spa_log log; diff --git a/spa/plugins/support/meson.build b/spa/plugins/support/meson.build index 9f24644fd..6fcbeff48 100644 --- a/spa/plugins/support/meson.build +++ b/spa/plugins/support/meson.build @@ -45,7 +45,10 @@ spa_dbus_lib = shared_library('spa-dbus', if systemd_dep.found() - spa_journal_sources = ['journal.c'] + spa_journal_sources = [ + 'journal.c', + 'log-patterns.c', + ] spa_journal_lib = shared_library('spa-journal', spa_journal_sources,