From a065cff8c1d65b2558a2381095c15a1dfba43f5c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 27 Feb 2026 16:06:33 +0100 Subject: [PATCH] zeroconf: pass user data as const --- src/modules/module-raop-discover.c | 4 ++-- src/modules/module-rtp-session.c | 4 ++-- src/modules/module-sendspin-recv.c | 4 ++-- src/modules/module-sendspin-send.c | 4 ++-- src/modules/module-zeroconf-discover.c | 8 ++------ src/modules/zeroconf-utils/zeroconf.c | 12 ++++++------ src/modules/zeroconf-utils/zeroconf.h | 8 ++++---- 7 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c index 60e5e0077..abe9b3dd8 100644 --- a/src/modules/module-raop-discover.c +++ b/src/modules/module-raop-discover.c @@ -364,7 +364,7 @@ static void pw_properties_from_zeroconf(const char *key, const char *value, } } -static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name, *str; @@ -417,7 +417,7 @@ done: pw_properties_free(props); } -static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name; diff --git a/src/modules/module-rtp-session.c b/src/modules/module-rtp-session.c index ffff2a517..f1f56d121 100644 --- a/src/modules/module-rtp-session.c +++ b/src/modules/module-rtp-session.c @@ -1280,7 +1280,7 @@ static const char *get_service_name(struct impl *impl) return NULL; } -static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *str, *service_name, *address, *hostname; @@ -1417,7 +1417,7 @@ error: return; } -static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; struct service_info sinfo; diff --git a/src/modules/module-sendspin-recv.c b/src/modules/module-sendspin-recv.c index 517679fba..a31681f24 100644 --- a/src/modules/module-sendspin-recv.c +++ b/src/modules/module-sendspin-recv.c @@ -1109,7 +1109,7 @@ static const struct pw_websocket_events websocket_events = { .connected = on_websocket_connected, }; -static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name, *addr, *port, *path; @@ -1138,7 +1138,7 @@ static void on_zeroconf_added(void *data, void *user, const struct spa_dict *inf match_client(impl, name, props, NULL); } -static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name; diff --git a/src/modules/module-sendspin-send.c b/src/modules/module-sendspin-send.c index c10a9aba9..c67abcc06 100644 --- a/src/modules/module-sendspin-send.c +++ b/src/modules/module-sendspin-send.c @@ -1110,7 +1110,7 @@ static const struct pw_websocket_events websocket_events = { .connected = on_websocket_connected, }; -static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name, *addr, *port, *path; @@ -1136,7 +1136,7 @@ static void on_zeroconf_added(void *data, void *user, const struct spa_dict *inf match_client(impl, name, props, NULL); } -static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name; diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index f6f1ce087..52b407687 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -20,10 +20,6 @@ #include #include -#include -#include -#include - #include "module-protocol-pulse/format.h" #include "zeroconf-utils/zeroconf.h" @@ -230,7 +226,7 @@ static const struct pw_impl_module_events submodule_events = { .destroy = submodule_destroy, }; -static void on_zeroconf_added(void *data, void *user_data, const struct spa_dict *info) +static void on_zeroconf_added(void *data, const void *user_data, const struct spa_dict *info) { struct impl *impl = data; const char *name, *type, *mode, *device, *host_name, *desc, *fqdn, *user, *str; @@ -344,7 +340,7 @@ done: pw_properties_free(props); } -static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info) +static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info) { struct impl *impl = data; const char *name, *type, *mode; diff --git a/src/modules/zeroconf-utils/zeroconf.c b/src/modules/zeroconf-utils/zeroconf.c index 7932c17cf..49ed0e70e 100644 --- a/src/modules/zeroconf-utils/zeroconf.c +++ b/src/modules/zeroconf-utils/zeroconf.c @@ -49,7 +49,7 @@ struct entry { #define TYPE_ANNOUNCE 0 #define TYPE_BROWSE 1 uint32_t type; - void *user; + const void *user; struct pw_properties *props; @@ -110,7 +110,7 @@ static void service_free(struct service *s) free(s); } -struct entry *entry_find(struct pw_zeroconf *zc, uint32_t type, void *user) +struct entry *entry_find(struct pw_zeroconf *zc, uint32_t type, const void *user) { struct entry *e; spa_list_for_each(e, &zc->entries, link) @@ -505,7 +505,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *d) zeroconf_unref(zc); } -static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info) +static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, const void *user, const struct spa_dict *info) { struct entry *e; @@ -524,7 +524,7 @@ static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, void *user return e; } -static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info) +static int set_entry(struct pw_zeroconf *zc, uint32_t type, const void *user, const struct spa_dict *info) { struct entry *e; int res = 0; @@ -546,11 +546,11 @@ static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const st } return res; } -int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info) +int pw_zeroconf_set_announce(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info) { return set_entry(zc, TYPE_ANNOUNCE, user, info); } -int pw_zeroconf_set_browse(struct pw_zeroconf *zc, void *user, const struct spa_dict *info) +int pw_zeroconf_set_browse(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info) { return set_entry(zc, TYPE_BROWSE, user, info); } diff --git a/src/modules/zeroconf-utils/zeroconf.h b/src/modules/zeroconf-utils/zeroconf.h index a5de62787..1b27e5d5b 100644 --- a/src/modules/zeroconf-utils/zeroconf.h +++ b/src/modules/zeroconf-utils/zeroconf.h @@ -22,8 +22,8 @@ struct pw_zeroconf_events { void (*destroy) (void *data); void (*error) (void *data, int err, const char *message); - void (*added) (void *data, void *user, const struct spa_dict *info); - void (*removed) (void *data, void *user, const struct spa_dict *info); + void (*added) (void *data, const void *user, const struct spa_dict *info); + void (*removed) (void *data, const void *user, const struct spa_dict *info); }; struct pw_zeroconf * pw_zeroconf_new(struct pw_context *context, @@ -31,8 +31,8 @@ struct pw_zeroconf * pw_zeroconf_new(struct pw_context *context, void pw_zeroconf_destroy(struct pw_zeroconf *zc); -int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info); -int pw_zeroconf_set_browse(struct pw_zeroconf *zc, void *user, const struct spa_dict *info); +int pw_zeroconf_set_announce(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info); +int pw_zeroconf_set_browse(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info); void pw_zeroconf_add_listener(struct pw_zeroconf *zc, struct spa_hook *listener,