From c05556421742eb47f80301767653a4bcb19de9de Mon Sep 17 00:00:00 2001 From: Ian Munsie Date: Tue, 13 Apr 2010 18:37:33 +1000 Subject: perf: Fix endianness argument compatibility with OPT_BOOLEAN() and introduce OPT_INCR() Parsing an option from the command line with OPT_BOOLEAN on a bool data type would not work on a big-endian machine due to the manner in which the boolean was being cast into an int and incremented. For example, running 'perf probe --list' on a PowerPC machine would fail to properly set the list_events bool and would therefore print out the usage information and terminate. This patch makes OPT_BOOLEAN work as expected with a bool datatype. For cases where the original OPT_BOOLEAN was intentionally being used to increment an int each time it was passed in on the command line, this patch introduces OPT_INCR with the old behaviour of OPT_BOOLEAN (the verbose variable is currently the only such example of this). I have reviewed every use of OPT_BOOLEAN to verify that a true C99 bool was passed. Where integers were used, I verified that they were only being used for boolean logic and changed them to bools to ensure that they would not be mistakenly used as ints. The major exception was the verbose variable which now uses OPT_INCR instead of OPT_BOOLEAN. Signed-off-by: Ian Munsie Acked-by: David S. Miller Cc: # NOTE: wont apply to .3[34].x cleanly, please backport Cc: Git development list Cc: Ian Munsie Cc: Peter Zijlstra Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: KOSAKI Motohiro Cc: Hitoshi Mitake Cc: Rusty Russell Cc: Frederic Weisbecker Cc: Eric B Munson Cc: Valdis.Kletnieks@vt.edu Cc: WANG Cong Cc: Thiago Farina Cc: Masami Hiramatsu Cc: Xiao Guangrong Cc: Jaswinder Singh Rajput Cc: Arjan van de Ven Cc: OGAWA Hirofumi Cc: Mike Galbraith Cc: Tom Zanussi Cc: Anton Blanchard Cc: John Kacur Cc: Li Zefan Cc: Steven Rostedt LKML-Reference: <1271147857-11604-1-git-send-email-imunsie@au.ibm.com> Signed-off-by: Ingo Molnar --- tools/perf/builtin-diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/perf/builtin-diff.c') diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 1ea15d8aeed..3a1d94d75dc 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -19,7 +19,7 @@ static char const *input_old = "perf.data.old", *input_new = "perf.data"; static char diff__default_sort_order[] = "dso,symbol"; -static int force; +static bool force; static bool show_displacement; static int perf_session__add_hist_entry(struct perf_session *self, @@ -188,7 +188,7 @@ static const char * const diff_usage[] = { }; static const struct option options[] = { - OPT_BOOLEAN('v', "verbose", &verbose, + OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('m', "displacement", &show_displacement, "Show position displacement relative to baseline"), -- cgit v1.2.3