perf tool: Fix gcc 4.6.0 issues
authorKyle McMartin <kyle@mcmartin.ca>
Mon, 24 Jan 2011 16:13:04 +0000 (11:13 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 7 Feb 2011 14:41:41 +0000 (12:41 -0200)
GCC 4.6.0 in Fedora rawhide turned up some compile errors in tools/perf
due to the -Werror=unused-but-set-variable flag.

I've gone through and annotated some of the assignments that had side
effects (ie: return value from a function) with the __used annotation,
and in some cases, just removed unused code.

In a few cases, we were assigning something useful, but not using it in
later parts of the function.

kyle@dreadnought:~/src% gcc --version
gcc (GCC) 4.6.0 20110122 (Red Hat 4.6.0-0.3)

Cc: Ingo Molnar <mingo@redhat.com>
LKML-Reference: <20110124161304.GK27353@bombadil.infradead.org>
Signed-off-by: Kyle McMartin <kyle@redhat.com>
[ committer note: Fixed up the annotation fixes, as that code moved recently ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/bench/sched-pipe.c
tools/perf/builtin-sched.c
tools/perf/builtin-top.c
tools/perf/util/annotate.c
tools/perf/util/header.c
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/symbol.c
tools/perf/util/trace-event-parse.c
tools/perf/util/ui/browsers/map.c

index d9ab3ce446acf88a4c86238dd3ea01e3c498b169..0c7454f8b8a9841f039568f5af0d74fecec0329e 100644 (file)
@@ -55,7 +55,7 @@ int bench_sched_pipe(int argc, const char **argv,
         * discarding returned value of read(), write()
         * causes error in building environment for perf
         */
-       int ret, wait_stat;
+       int __used ret, wait_stat;
        pid_t pid, retpid;
 
        argc = parse_options(argc, argv, options,
index ae26211829272c63039e3c63902d8c99cd6f56e6..a32f411faeac15f10fbd54e2cac2e547bcc0972f 100644 (file)
@@ -369,11 +369,6 @@ static void
 process_sched_event(struct task_desc *this_task __used, struct sched_atom *atom)
 {
        int ret = 0;
-       u64 now;
-       long long delta;
-
-       now = get_nsecs();
-       delta = start_time + atom->timestamp - now;
 
        switch (atom->type) {
                case SCHED_EVENT_RUN:
@@ -562,7 +557,7 @@ static void wait_for_tasks(void)
 
 static void run_one_test(void)
 {
-       u64 T0, T1, delta, avg_delta, fluct, std_dev;
+       u64 T0, T1, delta, avg_delta, fluct;
 
        T0 = get_nsecs();
        wait_for_tasks();
@@ -578,7 +573,6 @@ static void run_one_test(void)
        else
                fluct = delta - avg_delta;
        sum_fluct += fluct;
-       std_dev = sum_fluct / nr_runs / sqrt(nr_runs);
        if (!run_avg)
                run_avg = delta;
        run_avg = (run_avg*9 + delta)/10;
@@ -799,7 +793,7 @@ replay_switch_event(struct trace_switch_event *switch_event,
                    u64 timestamp,
                    struct thread *thread __used)
 {
-       struct task_desc *prev, *next;
+       struct task_desc *prev, __used *next;
        u64 timestamp0;
        s64 delta;
 
@@ -1404,7 +1398,7 @@ map_switch_event(struct trace_switch_event *switch_event,
                 u64 timestamp,
                 struct thread *thread __used)
 {
-       struct thread *sched_out, *sched_in;
+       struct thread *sched_out __used, *sched_in;
        int new_shortname;
        u64 timestamp0;
        s64 delta;
index 716118a3b3e475f4936e3fe1a79f535d67bff5ea..b790673cb0aa79abdc35fb0019e58adc51cc2064 100644 (file)
@@ -865,7 +865,7 @@ static int __cmd_top(void)
 {
        pthread_t thread;
        struct perf_evsel *first;
-       int ret;
+       int ret __used;
        /*
         * FIXME: perf_session__new should allow passing a O_MMAP, so that all this
         * mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
index 297337649c218474d6c1f81c2384512a847882dd..1012841835a303c5db5e2c6a06c5538fa9cb0785 100644 (file)
@@ -236,7 +236,6 @@ int symbol__annotate(struct symbol *sym, struct map *map,
        char command[PATH_MAX * 2];
        FILE *file;
        int err = 0;
-       u64 len;
        char symfs_filename[PATH_MAX];
 
        if (filename) {
@@ -281,8 +280,6 @@ fallback:
                 filename, sym->name, map->unmap_ip(map, sym->start),
                 map->unmap_ip(map, sym->end));
 
-       len = sym->end - sym->start;
-
        pr_debug("annotating [%p] %30s : [%p] %30s\n",
                 dso, dso->long_name, sym, sym->name);
 
index c0de5ec44145da3179a3db66a3042b397f775564..72c124dc5781beb7c80b6da34dcf426d87cb0867 100644 (file)
@@ -1145,7 +1145,7 @@ int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
 {
        union perf_event ev;
        ssize_t size = 0, aligned_size = 0, padding;
-       int err = 0;
+       int err __used = 0;
 
        memset(&ev, 0, sizeof(ev));
 
index c6d99334bdfa836c1adba2d613b658fadf20797b..2040b8538527361828ad7a4ad3e034b9c95755fd 100644 (file)
@@ -248,8 +248,7 @@ static void python_process_event(int cpu, void *data,
        context = PyCObject_FromVoidPtr(scripting_context, NULL);
 
        PyTuple_SetItem(t, n++, PyString_FromString(handler_name));
-       PyTuple_SetItem(t, n++,
-                       PyCObject_FromVoidPtr(scripting_context, NULL));
+       PyTuple_SetItem(t, n++, context);
 
        if (handler) {
                PyTuple_SetItem(t, n++, PyInt_FromLong(cpu));
index 7821d0e6866f10e745762cc02c57237461ae0f8d..3e193f8e3061f17242055e62412dd4f15bcd9733 100644 (file)
@@ -1525,8 +1525,8 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
                             symbol_conf.symfs, self->long_name);
                        break;
                case DSO__ORIG_GUEST_KMODULE:
-                       if (map->groups && map->groups->machine)
-                               root_dir = map->groups->machine->root_dir;
+                       if (map->groups && machine)
+                               root_dir = machine->root_dir;
                        else
                                root_dir = "";
                        snprintf(name, size, "%s%s%s", symbol_conf.symfs,
index 73a02223c62922125b0dddb97e8a26099d8fdcd8..d8e622dd738aaafe4ce2a586f426f95e94da9e48 100644 (file)
@@ -153,7 +153,7 @@ void parse_proc_kallsyms(char *file, unsigned int size __unused)
        char *next = NULL;
        char *addr_str;
        char ch;
-       int ret;
+       int ret __used;
        int i;
 
        line = strtok_r(file, "\n", &next);
index e5158369106eee37234baf658d18cddec0539bb5..8462bffe20bc84ad31a5a81019990ddcb5ab401e 100644 (file)
@@ -41,7 +41,7 @@ static int ui_entry__read(const char *title, char *bf, size_t size, int width)
 out_free_form:
        newtPopWindow();
        newtFormDestroy(form);
-       return 0;
+       return err;
 }
 
 struct map_browser {