perf config: Do not consider an error not to have any perfconfig file

While propagating the errors from perf_config(), which were being
completely ignored, everything stopped working for people without a
~/.perfconfig file, because the perf_config_set__init() was considering
an error not to have a .perfconfig file, duh, fix it by checking the
errno after the failed stat() call.

It should also not return an error when it says it is ignoring the file,
and also a empty file should not return an error either.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Taeung Song <treeze.taeung@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 8beeb00f ("perf config: Use new perf_config_set__init() to initialize config set")
Link: http://lkml.kernel.org/n/tip-ygpbab3apbs6l8wr97xedwks@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e572d088
...@@ -646,8 +646,13 @@ static int perf_config_set__init(struct perf_config_set *set) ...@@ -646,8 +646,13 @@ static int perf_config_set__init(struct perf_config_set *set)
goto out; goto out;
} }
if (stat(user_config, &st) < 0) if (stat(user_config, &st) < 0) {
if (errno == ENOENT)
ret = 0;
goto out_free; goto out_free;
}
ret = 0;
if (st.st_uid && (st.st_uid != geteuid())) { if (st.st_uid && (st.st_uid != geteuid())) {
warning("File %s not owned by current user or root, " warning("File %s not owned by current user or root, "
...@@ -655,11 +660,8 @@ static int perf_config_set__init(struct perf_config_set *set) ...@@ -655,11 +660,8 @@ static int perf_config_set__init(struct perf_config_set *set)
goto out_free; goto out_free;
} }
if (!st.st_size) if (st.st_size)
goto out_free; ret = perf_config_from_file(collect_config, user_config, set);
ret = perf_config_from_file(collect_config, user_config, set);
out_free: out_free:
free(user_config); free(user_config);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment