Skip to content

Commit

Permalink
ARM: perf: fix compiler warning with gcc 4.6.4 (and tidy code)
Browse files Browse the repository at this point in the history
GCC 4.6.4 spits out the following warning when building perf_event_v7.c:

arch/arm/kernel/perf_event_v7.c: In function 'krait_pmu_get_event_idx':
arch/arm/kernel/perf_event_v7.c:1927:6: warning: 'bit' may be used uninitialized in this function

While upgrading the version of gcc may solve this, the code can also be
organised to be more efficient by not carrying more local variables than
is necessary across the armv7pmu_get_event_idx function call.  If we set
'bit' to -1 (which is invalid for clear_bit) we can use that as an
indication whether we need to clear a bit after this function.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King committed Jun 19, 2014
1 parent a641f3a commit 6a78371
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/arm/kernel/perf_event_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ static int krait_pmu_get_event_idx(struct pmu_hw_events *cpuc,
struct perf_event *event)
{
int idx;
int bit;
int bit = -1;
unsigned int prefix;
unsigned int region;
unsigned int code;
Expand Down Expand Up @@ -1953,7 +1953,7 @@ static int krait_pmu_get_event_idx(struct pmu_hw_events *cpuc,
}

idx = armv7pmu_get_event_idx(cpuc, event);
if (idx < 0 && krait_event)
if (idx < 0 && bit >= 0)
clear_bit(bit, cpuc->used_mask);

return idx;
Expand Down

0 comments on commit 6a78371

Please sign in to comment.