mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-15 08:56:38 -05:00
pulse-server: make name in create_server const
constify the name in create_server() and make a copy of the name were it is needed instead of modifying the argument in-place.
This commit is contained in:
parent
47bf30d734
commit
d8f86ca6e5
2 changed files with 11 additions and 12 deletions
|
|
@ -38,18 +38,16 @@ static int module_native_protocol_tcp_load(struct client *client, struct module
|
||||||
{
|
{
|
||||||
struct module_native_protocol_tcp_data *data = module->user_data;
|
struct module_native_protocol_tcp_data *data = module->user_data;
|
||||||
struct impl *impl = client->impl;
|
struct impl *impl = client->impl;
|
||||||
char *address;
|
const char *address;
|
||||||
|
|
||||||
address = strdup(pw_properties_get(module->props, "pulse.tcp"));
|
if ((address = pw_properties_get(module->props, "pulse.tcp")) == NULL)
|
||||||
data->server = create_server(impl, address);
|
return -EIO;
|
||||||
free(address);
|
|
||||||
|
|
||||||
if (data->server == NULL)
|
if ((data->server = create_server(impl, address)) == NULL)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_log_info("loaded module %p id:%u name:%s", module, module->idx, module->name);
|
pw_log_info("loaded module %p id:%u name:%s", module, module->idx, module->name);
|
||||||
module_emit_loaded(module, 0);
|
module_emit_loaded(module, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ struct impl {
|
||||||
/* Functions that modules can use */
|
/* Functions that modules can use */
|
||||||
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
|
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
|
||||||
|
|
||||||
static struct server *create_server(struct impl *impl, char *address);
|
static struct server *create_server(struct impl *impl, const char *address);
|
||||||
static void server_free(struct server *server);
|
static void server_free(struct server *server);
|
||||||
|
|
||||||
#include "collect.c"
|
#include "collect.c"
|
||||||
|
|
@ -6068,7 +6068,7 @@ static bool is_stale_socket(struct server *server, int fd)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int make_local_socket(struct server *server, char *name)
|
static int make_local_socket(struct server *server, const char *name)
|
||||||
{
|
{
|
||||||
char runtime_dir[PATH_MAX];
|
char runtime_dir[PATH_MAX];
|
||||||
socklen_t size;
|
socklen_t size;
|
||||||
|
|
@ -6183,7 +6183,7 @@ static int create_pid_file(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int make_inet_socket(struct server *server, char *name)
|
static int make_inet_socket(struct server *server, const char *name)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int res, fd, on;
|
int res, fd, on;
|
||||||
|
|
@ -6194,9 +6194,10 @@ static int make_inet_socket(struct server *server, char *name)
|
||||||
col = strchr(name, ':');
|
col = strchr(name, ':');
|
||||||
if (col) {
|
if (col) {
|
||||||
struct in_addr ipv4;
|
struct in_addr ipv4;
|
||||||
|
char *n;
|
||||||
port = atoi(col+1);
|
port = atoi(col+1);
|
||||||
*col = '\0';
|
n = strndupa(name, col - name);
|
||||||
if (inet_pton(AF_INET, name, &ipv4) > 0)
|
if (inet_pton(AF_INET, n, &ipv4) > 0)
|
||||||
address = ntohl(ipv4.s_addr);
|
address = ntohl(ipv4.s_addr);
|
||||||
else
|
else
|
||||||
address = INADDR_ANY;
|
address = INADDR_ANY;
|
||||||
|
|
@ -6243,7 +6244,7 @@ error:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct server *create_server(struct impl *impl, char *address)
|
static struct server *create_server(struct impl *impl, const char *address)
|
||||||
{
|
{
|
||||||
int fd, res;
|
int fd, res;
|
||||||
struct server *server;
|
struct server *server;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue