diff --git a/compositor/xwayland.c b/compositor/xwayland.c index 30ace4bf9..032ea6e49 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -137,7 +137,7 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd str_printf(&exec_failure_msg, "Error: executing Xwayland as '%s' failed.\n", xserver); custom_env_init_from_environ(&child_env); - custom_env_set(&child_env, "WAYLAND_SOCKET", wayland_socket.str1); + custom_env_set_env_var(&child_env, "WAYLAND_SOCKET", wayland_socket.str1); envp = custom_env_get_envp(&child_env); const char *const argv[] = { diff --git a/shared/process-util.c b/shared/process-util.c index a8a24a657..1da62dcc2 100644 --- a/shared/process-util.c +++ b/shared/process-util.c @@ -76,11 +76,11 @@ custom_env_init_from_environ(struct custom_env *env) char **it; char **ep; - wl_array_init(&env->p); - env->finalized = false; + wl_array_init(&env->envp); + env->env_finalized = false; for (it = environ; *it; it++) { - ep = wl_array_add(&env->p, sizeof *ep); + ep = wl_array_add(&env->envp, sizeof *ep); assert(ep); *ep = strdup(*it); assert(*ep); @@ -90,21 +90,21 @@ custom_env_init_from_environ(struct custom_env *env) void custom_env_fini(struct custom_env *env) { - char **ep; + char **p; - wl_array_for_each(ep, &env->p) - free(*ep); + wl_array_for_each(p, &env->envp) + free(*p); - wl_array_release(&env->p); + wl_array_release(&env->envp); } static char ** -custom_env_find_element(struct custom_env *env, const char *name) +custom_env_get_env_var(struct custom_env *env, const char *name) { char **ep; size_t name_len = strlen(name); - wl_array_for_each(ep, &env->p) { + wl_array_for_each(ep, &env->envp) { char *entry = *ep; if (strncmp(entry, name, name_len) == 0 && @@ -117,18 +117,18 @@ custom_env_find_element(struct custom_env *env, const char *name) } void -custom_env_set(struct custom_env *env, const char *name, const char *value) +custom_env_set_env_var(struct custom_env *env, const char *name, const char *value) { char **ep; assert(strchr(name, '=') == NULL); - assert(!env->finalized); + assert(!env->env_finalized); - ep = custom_env_find_element(env, name); + ep = custom_env_get_env_var(env, name); if (ep) free(*ep); else - ep = wl_array_add(&env->p, sizeof *ep); + ep = wl_array_add(&env->envp, sizeof *ep); assert(ep); str_printf(ep, "%s=%s", name, value); @@ -140,14 +140,14 @@ custom_env_get_envp(struct custom_env *env) { char **ep; - assert(!env->finalized); + assert(!env->env_finalized); /* add terminating NULL */ - ep = wl_array_add(&env->p, sizeof *ep); + ep = wl_array_add(&env->envp, sizeof *ep); assert(ep); *ep = NULL; - env->finalized = true; + env->env_finalized = true; - return env->p.data; + return env->envp.data; } diff --git a/shared/process-util.h b/shared/process-util.h index 56c1b46d9..8f8ead7da 100644 --- a/shared/process-util.h +++ b/shared/process-util.h @@ -66,8 +66,8 @@ fdstr_close_all(struct fdstr *s); * between fork() and exec(). */ struct custom_env { - struct wl_array p; - bool finalized; + struct wl_array envp; + bool env_finalized; }; void @@ -77,7 +77,7 @@ void custom_env_fini(struct custom_env *env); void -custom_env_set(struct custom_env *env, const char *name, const char *value); +custom_env_set_env_var(struct custom_env *env, const char *name, const char *value); char *const * custom_env_get_envp(struct custom_env *env);