sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit a1c6052383d382d978ca597dc5fb280c0343db60
parent 2960b2c9b6c77d42f2696c1997bda965594e5dd4
Author: Antonin Décimo <antonin.decimo@gmail.com>
Date:   Thu,  4 Jun 2020 14:41:22 +0200

Log empty value if envvar is not defined

If the environment variable is not defined, getenv returns NULL.
Passing a NULL pointer to the "%s" format specifier is undefined
behavior. Even if some implementations output "(null)", an empty
string is nicer.

Diffstat:
Msway/main.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sway/main.c b/sway/main.c @@ -138,7 +138,8 @@ static void log_env(void) { "SWAYSOCK", }; for (size_t i = 0; i < sizeof(log_vars) / sizeof(char *); ++i) { - sway_log(SWAY_INFO, "%s=%s", log_vars[i], getenv(log_vars[i])); + char *value = getenv(log_vars[i]); + sway_log(SWAY_INFO, "%s=%s", log_vars[i], value != NULL ? value : ""); } }