]> git.baikalelectronics.ru Git - kernel.git/commit
perf env: Do not return pointers to local variables
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 2 Mar 2020 14:23:03 +0000 (11:23 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 2 Mar 2020 14:23:03 +0000 (11:23 -0300)
commit6c7a315453f1a362c3d5b21427c4d94163f06bc6
treedc434255f86483e86cb6675d7a37759bccf7b4b7
parentb99851b23b272166263953841cc362df57cafc8e
perf env: Do not return pointers to local variables

It is possible to return a pointer to a local variable when looking up
the architecture name for the running system and no normalization is
done on that value, i.e. we may end up returning the uts.machine local
variable.

While this doesn't happen on most arches, as normalization takes place,
lets fix this by making that a static variable and optimize it a bit by
not always running uname(), only the first time.

Noticed in fedora rawhide running with:

  [perfbuilder@a5ff49d6e6e4 ~]$ gcc --version
  gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)

Reported-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/env.c