• Taeung Song's avatar
    perf config: Fix abnormal termination at perf_parse_file() · 78f71c99
    Taeung Song authored
    If a config file has wrong key-value pairs, the perf process will be
    forcibly terminated by die() at perf_parse_file() called by
    perf_config() so terminal settings can be crushed because of unusual
    termination.
    
    For example:
    
    If user config file has a wrong value 'red;default' instead of a normal
    value like 'red, default' for a key 'colors.top',
    
        # cat ~/.perfconfig
        [colors]
            medium = red;default # wrong value
    
    and if running sub-command 'top',
    
        # perf top
    
    perf process is dead by force and terminal setting is broken
    with a messge like below.
    
        Fatal: bad config file line 2 in /root/.perfconfig
    
    So fix it.
    If perf_config() can return on failure without calling die()
    at perf_parse_file(), this problem can be solved.
    And if a config file has wrong values, show the error message
    and then use default config values instead of wrong config values.
    Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/1465210380-26749-2-git-send-email-treeze.taeung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    78f71c99
config.c 14.2 KB