perf stat: Avoid segfaults caused by negated options
authorMichael Petlan <mpetlan@redhat.com>
Mon, 10 Dec 2018 16:00:04 +0000 (11:00 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 18 Dec 2018 15:21:44 +0000 (12:21 -0300)
commit51433ead1460fb3f46e1c34f68bb22fd2dd0f5d0
tree3bc8c0f45e5d6f0ca143a358c326fe0215ff4bd9
parent4eaf97e8c5b13d01dd3c3b00181b6eed208aec01
perf stat: Avoid segfaults caused by negated options

Some 'perf stat' options do not make sense to be negated (event,
cgroup), some do not have negated path implemented (metrics). Due to
that, it is better to disable the "no-" prefix for them, since
otherwise, the later opt-parsing segfaults.

Before:

  $ perf stat --no-metrics -- ls
  Segmentation fault (core dumped)

After:

  $ perf stat --no-metrics -- ls
   Error: option `no-metrics' isn't available
   Usage: perf stat [<options>] [<command>]

Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
LPU-Reference: 1485912065.62416880.1544457604340.JavaMail.zimbra@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c