Ticket #3641: mc-3641-paths.c-reduce-scope-of-homedir-var.patch

File mc-3641-paths.c-reduce-scope-of-homedir-var.patch, 1.3 KB (added by mooffie, 8 years ago)

(See commit message. This is a followup to my previous patch.)

  • lib/mcconfig/paths.c

    From ce2213841ac6a19455a3e4ca548cc0a14f6b9088 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    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.
    ---
     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 4e2f2c5..7c34622 100644
    a b static char *mc_config_str = NULL; 
    5151static char *mc_cache_str = NULL; 
    5252static char *mc_data_str = NULL; 
    5353 
    54 static const char *homedir = NULL; 
    5554/* value of $MC_HOME */ 
    5655static const char *mc_home = NULL; 
    5756 
    mc_config_init_config_paths (GError ** mcerror) 
    296295    if (xdg_vars_initialized) 
    297296        return; 
    298297 
    299     /* init mc_home and homedir if not yet */ 
     298    /* init mc_home if not yet */ 
    300299    (void) mc_config_get_home_dir (); 
    301300 
    302301#if MC_HOMEDIR_XDG 
    mc_config_get_cache_path (void) 
    390389const char * 
    391390mc_config_get_home_dir (void) 
    392391{ 
     392    static const char *homedir = NULL; 
     393 
    393394    if (homedir == NULL) 
    394395    { 
    395396        homedir = g_getenv ("MC_HOME");