Permalink
Browse files

perf tools: Use __maybe_used for unused variables

perf defines both __used and __unused variables to use for marking
unused variables. The variable __used is defined to
__attribute__((__unused__)), which contradicts the kernel definition to
__attribute__((__used__)) for new gcc versions. On Android, __used is
also defined in system headers and this leads to warnings like: warning:
'__used__' attribute ignored

__unused is not defined in the kernel and is not a standard definition.
If __unused is included everywhere instead of __used, this leads to
conflicts with glibc headers, since glibc has a variables with this name
in its headers.

The best approach is to use __maybe_unused, the definition used in the
kernel for __attribute__((unused)). In this way there is only one
definition in perf sources (instead of 2 definitions that point to the
same thing: __used and __unused) and it works on both Linux and Android.
This patch simply replaces all instances of __used and __unused with
__maybe_unused.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1347315303-29906-7-git-send-email-irina.tirdea@intel.com
[ committer note: fixed up conflict with a116e05 in builtin-sched.c ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information...
1 parent 7dbf4dc commit 1d037ca1648b775277fc96401ec2aa233724906c @itirdea itirdea committed with Arnaldo Carvalho de Melo Sep 10, 2012
Showing with 498 additions and 418 deletions.
  1. +5 −3 tools/lib/traceevent/event-parse.c
  2. +2 −2 tools/lib/traceevent/event-parse.h
  3. +2 −1 tools/perf/bench/bench.h
  4. +1 −1 tools/perf/bench/mem-memcpy.c
  5. +1 −1 tools/perf/bench/mem-memset.c
  6. +1 −1 tools/perf/bench/sched-messaging.c
  7. +3 −3 tools/perf/bench/sched-pipe.c
  8. +1 −1 tools/perf/builtin-annotate.c
  9. +1 −1 tools/perf/builtin-bench.c
  10. +4 −3 tools/perf/builtin-buildid-cache.c
  11. +2 −1 tools/perf/builtin-buildid-list.c
  12. +2 −2 tools/perf/builtin-diff.c
  13. +1 −1 tools/perf/builtin-evlist.c
  14. +1 −1 tools/perf/builtin-help.c
  15. +13 −11 tools/perf/builtin-inject.c
  16. +12 −10 tools/perf/builtin-kmem.c
  17. +1 −1 tools/perf/builtin-kvm.c
  18. +1 −1 tools/perf/builtin-list.c
  19. +2 −2 tools/perf/builtin-lock.c
  20. +12 −12 tools/perf/builtin-probe.c
  21. +5 −5 tools/perf/builtin-record.c
  22. +6 −5 tools/perf/builtin-report.c
  23. +48 −54 tools/perf/builtin-sched.c
  24. +15 −14 tools/perf/builtin-script.c
  25. +28 −12 tools/perf/builtin-stat.c
  26. +6 −3 tools/perf/builtin-test.c
  27. +16 −14 tools/perf/builtin-timechart.c
  28. +4 −3 tools/perf/builtin-top.c
  29. +4 −3 tools/perf/ui/browser.c
  30. +4 −2 tools/perf/ui/browsers/annotate.c
  31. +3 −2 tools/perf/ui/gtk/browser.c
  32. +1 −1 tools/perf/ui/gtk/setup.c
  33. +2 −2 tools/perf/ui/gtk/util.c
  34. +1 −1 tools/perf/ui/helpline.c
  35. +4 −4 tools/perf/ui/helpline.h
  36. +11 −10 tools/perf/ui/hist.c
  37. +2 −2 tools/perf/ui/tui/setup.c
  38. +2 −1 tools/perf/util/alias.c
  39. +3 −3 tools/perf/util/annotate.c
  40. +7 −6 tools/perf/util/annotate.h
  41. +6 −5 tools/perf/util/build-id.c
  42. +3 −3 tools/perf/util/cache.h
  43. +3 −3 tools/perf/util/callchain.c
  44. +2 −2 tools/perf/util/cgroup.c
  45. +4 −2 tools/perf/util/config.c
  46. +5 −4 tools/perf/util/debug.h
  47. +10 −9 tools/perf/util/event.c
  48. +50 −43 tools/perf/util/header.c
  49. +2 −1 tools/perf/util/help.c
  50. +1 −1 tools/perf/util/hist.c
  51. +17 −15 tools/perf/util/hist.h
  52. +3 −1 tools/perf/util/include/linux/compiler.h
  53. +2 −2 tools/perf/util/intlist.c
  54. +1 −1 tools/perf/util/map.h
  55. +3 −3 tools/perf/util/parse-events-test.c
  56. +4 −3 tools/perf/util/parse-events.c
  57. +1 −1 tools/perf/util/parse-events.l
  58. +2 −2 tools/perf/util/parse-events.y
  59. +2 −1 tools/perf/util/parse-options.c
  60. +1 −1 tools/perf/util/perf_regs.h
  61. +3 −3 tools/perf/util/pmu.y
  62. +11 −10 tools/perf/util/probe-event.c
  63. +2 −2 tools/perf/util/probe-finder.c
  64. +5 −3 tools/perf/util/python.c
  65. +4 −4 tools/perf/util/scripting-engines/trace-event-perl.c
  66. +6 −4 tools/perf/util/scripting-engines/trace-event-python.c
  67. +27 −23 tools/perf/util/session.c
  68. +9 −5 tools/perf/util/sort.c
  69. +16 −12 tools/perf/util/symbol-minimal.c
  70. +1 −1 tools/perf/util/symbol.c
  71. +4 −3 tools/perf/util/symbol.h
  72. +2 −2 tools/perf/util/trace-event-parse.c
  73. +18 −15 tools/perf/util/trace-event-scripting.c
  74. +20 −16 tools/perf/util/unwind.c
  75. +6 −5 tools/perf/util/unwind.h
  76. +2 −1 tools/perf/util/wrapper.c
@@ -1824,7 +1824,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
}
static enum event_type
-process_entry(struct event_format *event __unused, struct print_arg *arg,
+process_entry(struct event_format *event __maybe_unused, struct print_arg *arg,
char **tok)
{
enum event_type type;
@@ -2458,7 +2458,8 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok)
static enum event_type
-process_str(struct event_format *event __unused, struct print_arg *arg, char **tok)
+process_str(struct event_format *event __maybe_unused, struct print_arg *arg,
+ char **tok)
{
enum event_type type;
char *token;
@@ -3653,7 +3654,8 @@ static void free_args(struct print_arg *args)
}
static char *
-get_bprint_format(void *data, int size __unused, struct event_format *event)
+get_bprint_format(void *data, int size __maybe_unused,
+ struct event_format *event)
{
struct pevent *pevent = event->pevent;
unsigned long long addr;
@@ -24,8 +24,8 @@
#include <stdarg.h>
#include <regex.h>
-#ifndef __unused
-#define __unused __attribute__ ((unused))
+#ifndef __maybe_unused
+#define __maybe_unused __attribute__((unused))
#endif
/* ----------------------- trace_seq ----------------------- */
View
@@ -3,7 +3,8 @@
extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
-extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
+extern int bench_mem_memcpy(int argc, const char **argv,
+ const char *prefix __maybe_unused);
extern int bench_mem_memset(int argc, const char **argv, const char *prefix);
#define BENCH_FORMAT_DEFAULT_STR "default"
@@ -177,7 +177,7 @@ static double do_memcpy_gettimeofday(memcpy_t fn, size_t len, bool prefault)
} while (0)
int bench_mem_memcpy(int argc, const char **argv,
- const char *prefix __used)
+ const char *prefix __maybe_unused)
{
int i;
size_t len;
@@ -171,7 +171,7 @@ static double do_memset_gettimeofday(memset_t fn, size_t len, bool prefault)
} while (0)
int bench_mem_memset(int argc, const char **argv,
- const char *prefix __used)
+ const char *prefix __maybe_unused)
{
int i;
size_t len;
@@ -267,7 +267,7 @@ static const char * const bench_sched_message_usage[] = {
};
int bench_sched_messaging(int argc, const char **argv,
- const char *prefix __used)
+ const char *prefix __maybe_unused)
{
unsigned int i, total_children;
struct timeval start, stop, diff;
@@ -43,7 +43,7 @@ static const char * const bench_sched_pipe_usage[] = {
};
int bench_sched_pipe(int argc, const char **argv,
- const char *prefix __used)
+ const char *prefix __maybe_unused)
{
int pipe_1[2], pipe_2[2];
int m = 0, i;
@@ -55,8 +55,8 @@ int bench_sched_pipe(int argc, const char **argv,
* discarding returned value of read(), write()
* causes error in building environment for perf
*/
- int __used ret, wait_stat;
- pid_t pid, retpid __used;
+ int __maybe_unused ret, wait_stat;
+ pid_t pid, retpid __maybe_unused;
argc = parse_options(argc, argv, options,
bench_sched_pipe_usage, 0);
@@ -239,7 +239,7 @@ static const char * const annotate_usage[] = {
NULL
};
-int cmd_annotate(int argc, const char **argv, const char *prefix __used)
+int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
{
struct perf_annotate annotate = {
.tool = {
@@ -173,7 +173,7 @@ static void all_subsystem(void)
all_suite(&subsystems[i]);
}
-int cmd_bench(int argc, const char **argv, const char *prefix __used)
+int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
{
int i, j, status = 0;
@@ -51,8 +51,8 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir)
return err;
}
-static int build_id_cache__remove_file(const char *filename __used,
- const char *debugdir __used)
+static int build_id_cache__remove_file(const char *filename __maybe_unused,
+ const char *debugdir __maybe_unused)
{
u8 build_id[BUILD_ID_SIZE];
char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -120,7 +120,8 @@ static int __cmd_buildid_cache(void)
return 0;
}
-int cmd_buildid_cache(int argc, const char **argv, const char *prefix __used)
+int cmd_buildid_cache(int argc, const char **argv,
+ const char *prefix __maybe_unused)
{
argc = parse_options(argc, argv, buildid_cache_options,
buildid_cache_usage, 0);
@@ -103,7 +103,8 @@ static int __cmd_buildid_list(void)
return perf_session__list_build_ids();
}
-int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
+int cmd_buildid_list(int argc, const char **argv,
+ const char *prefix __maybe_unused)
{
argc = parse_options(argc, argv, options, buildid_list_usage, 0);
setup_pager();
@@ -33,7 +33,7 @@ static int hists__add_entry(struct hists *self,
return -ENOMEM;
}
-static int diff__process_sample_event(struct perf_tool *tool __used,
+static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
@@ -242,7 +242,7 @@ static const struct option options[] = {
OPT_END()
};
-int cmd_diff(int argc, const char **argv, const char *prefix __used)
+int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
{
sort_order = diff__default_sort_order;
argc = parse_options(argc, argv, options, diff_usage, 0);
@@ -113,7 +113,7 @@ static const char * const evlist_usage[] = {
NULL
};
-int cmd_evlist(int argc, const char **argv, const char *prefix __used)
+int cmd_evlist(int argc, const char **argv, const char *prefix __maybe_unused)
{
struct perf_attr_details details = { .verbose = false, };
const char *input_name = NULL;
@@ -426,7 +426,7 @@ static int show_html_page(const char *perf_cmd)
return 0;
}
-int cmd_help(int argc, const char **argv, const char *prefix __used)
+int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
{
const char *alias;
int rc = 0;
@@ -17,9 +17,9 @@
static char const *input_name = "-";
static bool inject_build_ids;
-static int perf_event__repipe_synth(struct perf_tool *tool __used,
+static int perf_event__repipe_synth(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct machine *machine __used)
+ struct machine *machine __maybe_unused)
{
uint32_t size;
void *buf = event;
@@ -40,7 +40,8 @@ static int perf_event__repipe_synth(struct perf_tool *tool __used,
static int perf_event__repipe_op2_synth(struct perf_tool *tool,
union perf_event *event,
- struct perf_session *session __used)
+ struct perf_session *session
+ __maybe_unused)
{
return perf_event__repipe_synth(tool, event, NULL);
}
@@ -52,13 +53,14 @@ static int perf_event__repipe_event_type_synth(struct perf_tool *tool,
}
static int perf_event__repipe_tracing_data_synth(union perf_event *event,
- struct perf_session *session __used)
+ struct perf_session *session
+ __maybe_unused)
{
return perf_event__repipe_synth(NULL, event, NULL);
}
static int perf_event__repipe_attr(union perf_event *event,
- struct perf_evlist **pevlist __used)
+ struct perf_evlist **pevlist __maybe_unused)
{
int ret;
ret = perf_event__process_attr(event, pevlist);
@@ -70,16 +72,16 @@ static int perf_event__repipe_attr(union perf_event *event,
static int perf_event__repipe(struct perf_tool *tool,
union perf_event *event,
- struct perf_sample *sample __used,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
return perf_event__repipe_synth(tool, event, machine);
}
static int perf_event__repipe_sample(struct perf_tool *tool,
union perf_event *event,
- struct perf_sample *sample __used,
- struct perf_evsel *evsel __used,
+ struct perf_sample *sample __maybe_unused,
+ struct perf_evsel *evsel __maybe_unused,
struct machine *machine)
{
return perf_event__repipe_synth(tool, event, machine);
@@ -163,7 +165,7 @@ static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
static int perf_event__inject_buildid(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
- struct perf_evsel *evsel __used,
+ struct perf_evsel *evsel __maybe_unused,
struct machine *machine)
{
struct addr_location al;
@@ -224,7 +226,7 @@ struct perf_tool perf_inject = {
extern volatile int session_done;
-static void sig_handler(int sig __attribute__((__unused__)))
+static void sig_handler(int sig __maybe_unused)
{
session_done = 1;
}
@@ -267,7 +269,7 @@ static const struct option options[] = {
OPT_END()
};
-int cmd_inject(int argc, const char **argv, const char *prefix __used)
+int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
{
argc = parse_options(argc, argv, options, report_usage, 0);
View
@@ -320,7 +320,7 @@ static int perf_evsel__process_kmem_event(struct perf_evsel *evsel,
return 0;
}
-static int process_sample_event(struct perf_tool *tool __used,
+static int process_sample_event(struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
@@ -672,8 +672,8 @@ static int setup_sorting(struct list_head *sort_list, const char *arg)
return 0;
}
-static int parse_sort_opt(const struct option *opt __used,
- const char *arg, int unset __used)
+static int parse_sort_opt(const struct option *opt __maybe_unused,
+ const char *arg, int unset __maybe_unused)
{
if (!arg)
return -1;
@@ -686,22 +686,24 @@ static int parse_sort_opt(const struct option *opt __used,
return 0;
}
-static int parse_caller_opt(const struct option *opt __used,
- const char *arg __used, int unset __used)
+static int parse_caller_opt(const struct option *opt __maybe_unused,
+ const char *arg __maybe_unused,
+ int unset __maybe_unused)
{
caller_flag = (alloc_flag + 1);
return 0;
}
-static int parse_alloc_opt(const struct option *opt __used,
- const char *arg __used, int unset __used)
+static int parse_alloc_opt(const struct option *opt __maybe_unused,
+ const char *arg __maybe_unused,
+ int unset __maybe_unused)
{
alloc_flag = (caller_flag + 1);
return 0;
}
-static int parse_line_opt(const struct option *opt __used,
- const char *arg, int unset __used)
+static int parse_line_opt(const struct option *opt __maybe_unused,
+ const char *arg, int unset __maybe_unused)
{
int lines;
@@ -771,7 +773,7 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
}
-int cmd_kmem(int argc, const char **argv, const char *prefix __used)
+int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
{
argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
View
@@ -102,7 +102,7 @@ static int __cmd_buildid_list(int argc, const char **argv)
return cmd_buildid_list(i, rec_argv, NULL);
}
-int cmd_kvm(int argc, const char **argv, const char *prefix __used)
+int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
{
perf_host = 0;
perf_guest = 1;
@@ -14,7 +14,7 @@
#include "util/parse-events.h"
#include "util/cache.h"
-int cmd_list(int argc, const char **argv, const char *prefix __used)
+int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
setup_pager();
@@ -870,7 +870,7 @@ static int dump_info(void)
return rc;
}
-static int process_sample_event(struct perf_tool *tool __used,
+static int process_sample_event(struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
@@ -1020,7 +1020,7 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
}
-int cmd_lock(int argc, const char **argv, const char *prefix __used)
+int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
{
unsigned int i;
int rc = 0;
Oops, something went wrong.

0 comments on commit 1d037ca

Please sign in to comment.