Skip to content

Commit

Permalink
src: const annotate the bluetooth plugin API
Browse files Browse the repository at this point in the history
The data was never mutable, so there's no API/ABI breakage here.
  • Loading branch information
evelikov-work authored and Vudentz committed Jan 19, 2024
1 parent 2ef2f12 commit 00f1ddf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/genbuiltin
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

for i in $*
do
echo "extern struct bluetooth_plugin_desc __bluetooth_builtin_$i;"
echo "extern const struct bluetooth_plugin_desc __bluetooth_builtin_$i;"
done

echo
echo "static struct bluetooth_plugin_desc *__bluetooth_builtin[] = {"
echo "static const struct bluetooth_plugin_desc *__bluetooth_builtin[] = {"

for i in $*
do
Expand Down
2 changes: 1 addition & 1 deletion src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern struct btd_debug_desc __stop___debug[];

static char **enabled = NULL;

static gboolean is_enabled(struct btd_debug_desc *desc)
static gboolean is_enabled(const struct btd_debug_desc *desc)
{
int i;

Expand Down
7 changes: 4 additions & 3 deletions src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static GSList *plugins = NULL;
struct bluetooth_plugin {
void *handle;
gboolean active;
struct bluetooth_plugin_desc *desc;
const struct bluetooth_plugin_desc *desc;
};

static int compare_priority(gconstpointer a, gconstpointer b)
Expand All @@ -42,7 +42,8 @@ static int compare_priority(gconstpointer a, gconstpointer b)
return plugin2->desc->priority - plugin1->desc->priority;
}

static gboolean add_plugin(void *handle, struct bluetooth_plugin_desc *desc)
static gboolean add_plugin(void *handle,
const struct bluetooth_plugin_desc *desc)
{
struct bluetooth_plugin *plugin;

Expand Down Expand Up @@ -141,7 +142,7 @@ gboolean plugin_init(const char *enable, const char *disable)
goto start;

while ((file = g_dir_read_name(dir)) != NULL) {
struct bluetooth_plugin_desc *desc;
const struct bluetooth_plugin_desc *desc;
void *handle;
char *filename;

Expand Down
8 changes: 5 additions & 3 deletions src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ struct bluetooth_plugin_desc {

#ifdef BLUETOOTH_PLUGIN_BUILTIN
#define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \
struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \
const struct bluetooth_plugin_desc \
__bluetooth_builtin_ ## name = { \
#name, version, priority, init, exit \
};
#else
Expand All @@ -32,9 +33,10 @@ struct bluetooth_plugin_desc {
__attribute__ ((weak, visibility("hidden"))); \
extern struct btd_debug_desc __stop___debug[] \
__attribute__ ((weak, visibility("hidden"))); \
extern struct bluetooth_plugin_desc bluetooth_plugin_desc \
extern const struct bluetooth_plugin_desc \
bluetooth_plugin_desc \
__attribute__ ((visibility("default"))); \
struct bluetooth_plugin_desc bluetooth_plugin_desc = { \
const struct bluetooth_plugin_desc bluetooth_plugin_desc = { \
#name, version, priority, init, exit, \
__start___debug, __stop___debug \
};
Expand Down

0 comments on commit 00f1ddf

Please sign in to comment.