Context |
Check |
Description |
tedd_an/pre-ci_am |
success
|
Success
|
tedd_an/CheckPatch |
warning
|
WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else
#108: FILE: src/plugin.c:52:
+ if (err == -ENOSYS || err == -ENOTSUP)
/github/workspace/src/src/13529372.patch total: 0 errors, 1 warnings, 105 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13529372.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
|
tedd_an/GitLint |
success
|
Gitlint PASS
|
tedd_an/IncrementalBuild |
fail
|
[BlueZ,v2,7/8] bluetoothd: change plugin loading alike obexd
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12763:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12763 | int main(int argc, char *argv[])
| ^~~~
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
766 | int main(int argc, char *argv[])
| ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
989 | int main(int argc, char *argv[])
| ^~~~
src/plugin.c: In function ‘init_plugin’:
src/plugin.c:59:1: error: no return statement in function returning non-void [-Werror=return-type]
59 | }
| ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10849: src/bluetoothd-plugin.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4638: all] Error 2
|
@@ -32,7 +32,6 @@ struct bluetooth_plugin {
#if EXTERNAL_PLUGINS
void *handle;
#endif
- gboolean active;
const struct bluetooth_plugin_desc *desc;
};
@@ -44,6 +43,21 @@ static int compare_priority(gconstpointer a, gconstpointer b)
return plugin2->desc->priority - plugin1->desc->priority;
}
+static int init_plugin(const struct bluetooth_plugin_desc *desc)
+{
+ int err;
+
+ err = desc->init();
+ if (err < 0) {
+ if (err == -ENOSYS || err == -ENOTSUP)
+ warn("System does not support %s plugin",
+ desc->name);
+ else
+ error("Failed to init %s plugin",
+ desc->name);
+ }
+}
+
#if EXTERNAL_PLUGINS
static gboolean add_external_plugin(void *handle,
const struct bluetooth_plugin_desc *desc)
@@ -58,19 +72,22 @@ static gboolean add_external_plugin(void *handle,
return FALSE;
}
- DBG("Loading %s plugin", desc->name);
-
plugin = g_try_new0(struct bluetooth_plugin, 1);
if (plugin == NULL)
return FALSE;
plugin->handle = handle;
- plugin->active = FALSE;
plugin->desc = desc;
+ if (init_plugin(desc) < 0) {
+ g_free(plugin);
+ return FALSE;
+ }
+
__btd_enable_debug(desc->debug_start, desc->debug_stop);
plugins = g_slist_insert_sorted(plugins, plugin, compare_priority);
+ DBG("Plugin %s loaded", desc->name);
return TRUE;
}
@@ -88,7 +105,13 @@ static void add_plugin(const struct bluetooth_plugin_desc *desc)
plugin->desc = desc;
+ if (init_plugin(desc) < 0) {
+ g_free(plugin);
+ return;
+ }
+
plugins = g_slist_insert_sorted(plugins, plugin, compare_priority);
+ DBG("Plugin %s loaded", desc->name);
}
static gboolean enable_plugin(const char *name, char **cli_enable,
@@ -181,7 +204,6 @@ static void external_plugin_init(char **cli_disabled, char **cli_enabled)
void plugin_init(const char *enable, const char *disable)
{
- GSList *list;
char **cli_disabled = NULL;
char **cli_enabled = NULL;
unsigned int i;
@@ -208,24 +230,6 @@ void plugin_init(const char *enable, const char *disable)
external_plugin_init(cli_enabled, cli_disabled);
- for (list = plugins; list; list = list->next) {
- struct bluetooth_plugin *plugin = list->data;
- int err;
-
- err = plugin->desc->init();
- if (err < 0) {
- if (err == -ENOSYS || err == -ENOTSUP)
- warn("System does not support %s plugin",
- plugin->desc->name);
- else
- error("Failed to init %s plugin",
- plugin->desc->name);
- continue;
- }
-
- plugin->active = TRUE;
- }
-
g_strfreev(cli_enabled);
g_strfreev(cli_disabled);
}
@@ -239,7 +243,7 @@ void plugin_cleanup(void)
for (list = plugins; list; list = list->next) {
struct bluetooth_plugin *plugin = list->data;
- if (plugin->active == TRUE && plugin->desc->exit)
+ if (plugin->desc->exit)
plugin->desc->exit();
#if EXTERNAL_PLUGINS
From: Emil Velikov <emil.velikov@collabora.com> Currently, we print "Loading foobar" for every plugin, before we try the respective init() callback. Instead we handle the latter in a bunch, at the end of the process. Do the init() call early, print "Loaded" once it's actually successful and drop the no-longer "active" tracking. --- src/plugin.c | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-)