diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-05-07 01:09:02 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-07 16:30:21 -0400 |
commit | 16ad2ffb822cd28e2330284a60fdfec8bb90bbb0 (patch) | |
tree | 4455824202a98540493d75dc5333f77cb42b59ba /tools/perf/builtin-top.c | |
parent | dfe78adaaca90417ece98edbd3eb1c9661334406 (diff) |
perf tools: Introduce perf_target__strerror()
The perf_target__strerror() sets @buf to a string that describes the
(perf_target-specific) error condition that is passed via @errnum.
This is similar to strerror_r() and does same thing if @errnum has a
standard errno value.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Reviewed-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1336367344-28071-6-git-send-email-namhyung.kim@lge.com
[ committer note: No need to use PERF_ERRNO_TARGET__SUCCESS, use shorter idiom ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c9137ba580d9..7ba0f03c0132 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1150,7 +1150,8 @@ static const char * const top_usage[] = { | |||
1150 | int cmd_top(int argc, const char **argv, const char *prefix __used) | 1150 | int cmd_top(int argc, const char **argv, const char *prefix __used) |
1151 | { | 1151 | { |
1152 | struct perf_evsel *pos; | 1152 | struct perf_evsel *pos; |
1153 | int status = -ENOMEM; | 1153 | int status; |
1154 | char errbuf[BUFSIZ]; | ||
1154 | struct perf_top top = { | 1155 | struct perf_top top = { |
1155 | .count_filter = 5, | 1156 | .count_filter = 5, |
1156 | .delay_secs = 2, | 1157 | .delay_secs = 2, |
@@ -1252,10 +1253,22 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1252 | 1253 | ||
1253 | setup_browser(false); | 1254 | setup_browser(false); |
1254 | 1255 | ||
1255 | perf_target__validate(&top.target); | 1256 | status = perf_target__validate(&top.target); |
1257 | if (status) { | ||
1258 | perf_target__strerror(&top.target, status, errbuf, BUFSIZ); | ||
1259 | ui__warning("%s", errbuf); | ||
1260 | } | ||
1261 | |||
1262 | status = perf_target__parse_uid(&top.target); | ||
1263 | if (status) { | ||
1264 | int saved_errno = errno; | ||
1256 | 1265 | ||
1257 | if (perf_target__parse_uid(&top.target) < 0) | 1266 | perf_target__strerror(&top.target, status, errbuf, BUFSIZ); |
1267 | ui__warning("%s", errbuf); | ||
1268 | |||
1269 | status = -saved_errno; | ||
1258 | goto out_delete_evlist; | 1270 | goto out_delete_evlist; |
1271 | } | ||
1259 | 1272 | ||
1260 | if (top.target.tid == 0 && top.target.pid == 0 && | 1273 | if (top.target.tid == 0 && top.target.pid == 0 && |
1261 | top.target.uid_str == NULL) | 1274 | top.target.uid_str == NULL) |