From 61f4ef98b90c1ac9057cc894c178e920d910b723 Mon Sep 17 00:00:00 2001 From: Mooffie Date: Thu, 8 Sep 2016 17:07:27 +0300 Subject: [PATCH] lib/mcconfig/paths.c: reduce scope of 'homedir' var. To ensure that nobody uses the 'homedir' variable in the future without initializing it first, we make it private to the function, thereby effectively removing it. Signed-off-by: Andrew Borodin --- lib/mcconfig/paths.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/mcconfig/paths.c b/lib/mcconfig/paths.c index 4e2f2c529..7c3462234 100644 --- a/lib/mcconfig/paths.c +++ b/lib/mcconfig/paths.c @@ -51,7 +51,6 @@ static char *mc_config_str = NULL; static char *mc_cache_str = NULL; static char *mc_data_str = NULL; -static const char *homedir = NULL; /* value of $MC_HOME */ static const char *mc_home = NULL; @@ -296,7 +295,7 @@ mc_config_init_config_paths (GError ** mcerror) if (xdg_vars_initialized) return; - /* init mc_home and homedir if not yet */ + /* init mc_home if not yet */ (void) mc_config_get_home_dir (); #if MC_HOMEDIR_XDG @@ -390,6 +389,8 @@ mc_config_get_cache_path (void) const char * mc_config_get_home_dir (void) { + static const char *homedir = NULL; + if (homedir == NULL) { homedir = g_getenv ("MC_HOME"); -- 2.11.4.GIT