perf list: Remove a level of indentation
PATCH 1/2 perf list: Remove a level of indentation
With a return after the if check an indentation level can be removed. Indentation shift only; no functional changes.
--- tools/perf/builtin-list.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-)
tools/perf/builtin-list.c +37 -36
@@ -17,48 +17,49 @@int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) { +int i; +setup_pager (); -if (argc ==1 ) +if (argc ==1 ) {print_events (NULL , false); -else { -int i; - -for (i =1 ; i < argc; ++i) { -if (i >2 ) -putchar ('\n' ); -if (strncmp (argv[i],"tracepoint" ,10 ) ==0 ) -print_tracepoint_events (NULL ,NULL , false); -else if (strcmp (argv[i],"hw" ) ==0 || -strcmp (argv[i],"hardware" ) ==0 ) -print_events_type (PERF_TYPE_HARDWARE ); -else if (strcmp (argv[i],"sw" ) ==0 || -strcmp (argv[i],"software" ) ==0 ) -print_events_type (PERF_TYPE_SOFTWARE ); -else if (strcmp (argv[i],"cache" ) ==0 || -strcmp (argv[i],"hwcache" ) ==0 ) -print_hwcache_events (NULL , false); -else if (strcmp (argv[i],"pmu" ) ==0 ) -print_pmu_events (NULL , false); -else if (strcmp (argv[i],"--raw-dump" ) ==0 ) -print_events (NULL , true); -else { -char *sep =strchr (argv[i],':' ), *s; -int sep_idx; +return 0 ; + } -if (sep ==NULL ) { -print_events (argv[i], false); -continue ; - } - sep_idx = sep - argv[i]; - s =strdup (argv[i]); -if (s ==NULL ) -return -1 ; +for (i =1 ; i < argc; ++i) { +if (i >2 ) +putchar ('\n' ); +if (strncmp (argv[i],"tracepoint" ,10 ) ==0 ) +print_tracepoint_events (NULL ,NULL , false); +else if (strcmp (argv[i],"hw" ) ==0 || +strcmp (argv[i],"hardware" ) ==0 ) +print_events_type (PERF_TYPE_HARDWARE ); +else if (strcmp (argv[i],"sw" ) ==0 || +strcmp (argv[i],"software" ) ==0 ) +print_events_type (PERF_TYPE_SOFTWARE ); +else if (strcmp (argv[i],"cache" ) ==0 || +strcmp (argv[i],"hwcache" ) ==0 ) +print_hwcache_events (NULL , false); +else if (strcmp (argv[i],"pmu" ) ==0 ) +print_pmu_events (NULL , false); +else if (strcmp (argv[i],"--raw-dump" ) ==0 ) +print_events (NULL , true); +else { +char *sep =strchr (argv[i],':' ), *s; +int sep_idx; - s[sep_idx] ='\0' ; -print_tracepoint_events (s, s + sep_idx +1 , false); -free (s); +if (sep ==NULL ) { +print_events (argv[i], false); +continue ; } + sep_idx = sep - argv[i]; + s =strdup (argv[i]); +if (s ==NULL ) +return -1 ; + + s[sep_idx] ='\0' ; +print_tracepoint_events (s, s + sep_idx +1 , false); +free (s); } }return 0 ;
Signature · 1 line
1.8.3.4 (Apple Git-47)
PATCH 2/2 perf list: Add usage
Currently perf list is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
--- tools/perf/builtin-list.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/perf/builtin-list.c +11 -0
@@ -14,10 +14,21 @@#include "util/parse-events.h" #include "util/cache.h" #include "util/pmu.h" +#include "util/parse-options.h" int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {int i; +const struct option list_options[] = { +OPT_END () + }; +const char *const list_usage[] = { +"perf list [hw|sw|cache|tracepoint|pmu|event_glob]" , +NULL + }; + + argc =parse_options (argc, argv, list_options, list_usage, +PARSE_OPT_STOP_AT_NON_OPTION );setup_pager ();
Signature · 1 line
1.8.3.4 (Apple Git-47)
Re: [PATCH 2/2] perf list: Add usage
Quoted 9 lines · David Ahern
Currently perf list is not very helpful if you forget the syntax:
$ perf list -hList of pre-defined events (to be used in -e):
After:
$ perf list -husage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
gah, this version breaks perf-list. Updated patch attached.
Quoted 1 line
From
d08747060ba5af3507831e0265044be17636869dMon Sep 17 00:00:00 2001
From: David Ahern <[email protected]>
Date: Wed, 30 Oct 2013 10:26:45 -0600
Subject: [PATCH 2/2] perf list: Add usage - v2
Currently perf list is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
v2: reset index counter based on option parsing.
--- tools/perf/builtin-list.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
tools/perf/builtin-list.c +14 -3
@@ -14,20 +14,31 @@#include "util/parse-events.h" #include "util/cache.h" #include "util/pmu.h" +#include "util/parse-options.h" int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {int i; +const struct option list_options[] = { +OPT_END () + }; +const char *const list_usage[] = { +"perf list [hw|sw|cache|tracepoint|pmu|event_glob]" , +NULL + }; + + argc =parse_options (argc, argv, list_options, list_usage, +PARSE_OPT_STOP_AT_NON_OPTION );setup_pager (); -if (argc ==1 ) { +if (argc ==0 ) {print_events (NULL , false);return 0 ; } -for (i =1 ; i < argc; ++i) { -if (i >2 ) +for (i =0 ; i < argc; ++i) { +if (i)putchar ('\n' );if (strncmp (argv[i],"tracepoint" ,10 ) ==0 )print_tracepoint_events (NULL ,NULL , false);
Signature · 1 line
1.8.3.4 (Apple Git-47)
Re: [PATCH 2/2] perf list: Add usage
In reply to David AhernQuoted 17 lines · David Ahern
Currently perf list is not very helpful if you forget the syntax:
$ perf list -hList of pre-defined events (to be used in -e):
After:
$ perf list -husage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
Signed-off-by David Ahern <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Stephane Eranian <[email protected]>
Quoted 3 lines
--- tools/perf/builtin-list.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Ingo
Quoted 10 lines · David Ahern
With a return after the if check an indentation level can be removed. Indentation shift only; no functional changes.
Signed-off-by David Ahern <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Jiri Olsa <[email protected]>Cc Namhyung Kim <[email protected]>Cc Stephane Eranian <[email protected]>
Haven't tested it but it looks like a good change.
Thanks,
Ingo
tip-bot for David Ahern
merge botperf list: Remove a level of indentation
Commit-ID: 8e00ddc9dfe09ee131144fdaf6c96ebe95bbbbcb Gitweb: http://git.kernel.org/tip/8e00ddc9dfe09ee131144fdaf6c96ebe95bbbbcb Author: David Ahern <[email protected]> AuthorDate: Wed, 30 Oct 2013 10:15:06 -0600 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 5 Nov 2013 14:25:26 -0300
perf list: Remove a level of indentation
With a return after the if check an indentation level can be removed. Indentation shift only; no functional changes.
--- tools/perf/builtin-list.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-)
tools/perf/builtin-list.c +37 -36
@@ -17,48 +17,49 @@int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) { +int i; +setup_pager (); -if (argc ==1 ) +if (argc ==1 ) {print_events (NULL , false); -else { -int i; - -for (i =1 ; i < argc; ++i) { -if (i >2 ) -putchar ('\n' ); -if (strncmp (argv[i],"tracepoint" ,10 ) ==0 ) -print_tracepoint_events (NULL ,NULL , false); -else if (strcmp (argv[i],"hw" ) ==0 || -strcmp (argv[i],"hardware" ) ==0 ) -print_events_type (PERF_TYPE_HARDWARE ); -else if (strcmp (argv[i],"sw" ) ==0 || -strcmp (argv[i],"software" ) ==0 ) -print_events_type (PERF_TYPE_SOFTWARE ); -else if (strcmp (argv[i],"cache" ) ==0 || -strcmp (argv[i],"hwcache" ) ==0 ) -print_hwcache_events (NULL , false); -else if (strcmp (argv[i],"pmu" ) ==0 ) -print_pmu_events (NULL , false); -else if (strcmp (argv[i],"--raw-dump" ) ==0 ) -print_events (NULL , true); -else { -char *sep =strchr (argv[i],':' ), *s; -int sep_idx; +return 0 ; + } -if (sep ==NULL ) { -print_events (argv[i], false); -continue ; - } - sep_idx = sep - argv[i]; - s =strdup (argv[i]); -if (s ==NULL ) -return -1 ; +for (i =1 ; i < argc; ++i) { +if (i >2 ) +putchar ('\n' ); +if (strncmp (argv[i],"tracepoint" ,10 ) ==0 ) +print_tracepoint_events (NULL ,NULL , false); +else if (strcmp (argv[i],"hw" ) ==0 || +strcmp (argv[i],"hardware" ) ==0 ) +print_events_type (PERF_TYPE_HARDWARE ); +else if (strcmp (argv[i],"sw" ) ==0 || +strcmp (argv[i],"software" ) ==0 ) +print_events_type (PERF_TYPE_SOFTWARE ); +else if (strcmp (argv[i],"cache" ) ==0 || +strcmp (argv[i],"hwcache" ) ==0 ) +print_hwcache_events (NULL , false); +else if (strcmp (argv[i],"pmu" ) ==0 ) +print_pmu_events (NULL , false); +else if (strcmp (argv[i],"--raw-dump" ) ==0 ) +print_events (NULL , true); +else { +char *sep =strchr (argv[i],':' ), *s; +int sep_idx; - s[sep_idx] ='\0' ; -print_tracepoint_events (s, s + sep_idx +1 , false); -free (s); +if (sep ==NULL ) { +print_events (argv[i], false); +continue ; } + sep_idx = sep - argv[i]; + s =strdup (argv[i]); +if (s ==NULL ) +return -1 ; + + s[sep_idx] ='\0' ; +print_tracepoint_events (s, s + sep_idx +1 , false); +free (s); } }return 0 ;
tip-bot for David Ahern
merge bot[tip:perf/core] perf list: Add usage
In reply to David Ahernperf list: Add usage
Commit-ID: 44d742e01e6d3dd544ee1873b660a3c8bc1413bb Gitweb: http://git.kernel.org/tip/44d742e01e6d3dd544ee1873b660a3c8bc1413bb Author: David Ahern <[email protected]> AuthorDate: Wed, 30 Oct 2013 10:28:29 -0600 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 5 Nov 2013 14:26:41 -0300
perf list: Add usage
Currently 'perf list' is not very helpful if you forget the syntax:
$ perf list -h
List of pre-defined events (to be used in -e):
After:
$ perf list -h
usage: perf list [hw|sw|cache|tracepoint|pmu|event_glob]
--- tools/perf/builtin-list.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
tools/perf/builtin-list.c +14 -3
@@ -14,20 +14,31 @@#include "util/parse-events.h" #include "util/cache.h" #include "util/pmu.h" +#include "util/parse-options.h" int cmd_list (int argc,const char **argv,const char *prefix__maybe_unused ) {int i; +const struct option list_options[] = { +OPT_END () + }; +const char *const list_usage[] = { +"perf list [hw|sw|cache|tracepoint|pmu|event_glob]" , +NULL + }; + + argc =parse_options (argc, argv, list_options, list_usage, +PARSE_OPT_STOP_AT_NON_OPTION );setup_pager (); -if (argc ==1 ) { +if (argc ==0 ) {print_events (NULL , false);return 0 ; } -for (i =1 ; i < argc; ++i) { -if (i >2 ) +for (i =0 ; i < argc; ++i) { +if (i)putchar ('\n' );if (strncmp (argv[i],"tracepoint" ,10 ) ==0 )print_tracepoint_events (NULL ,NULL , false);