diff options
author | Mathieu Poirier <mathieu.poirier@linaro.org> | 2016-05-16 16:55:55 -0600 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2016-06-20 11:16:07 -0600 |
commit | c14318faac87ba59c2ec8279e6328c774af3b723 (patch) | |
tree | ec304711315ffeebea9ca7d2e37a16cca2a35077 /tools | |
parent | 0951a97ed934668b87371c2d3d0c3d21659da4df (diff) |
cs-etm: avoid casting variable
Because of two's complement reprensentation, casting an int to
and unsigned value doesn't simply get rid of the negative sign.
As such a value of -1 becomes 0xFFFFFFFF, which is clearly not
the desired effect.
This patch deals with cases when @cpu has the value of -1. In
those cases queue '0' is initially selected.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/cs-etm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 0e9a0d07f03a..1c7208840823 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -938,10 +938,12 @@ static struct cs_etm_queue *cs_etm__cpu_to_etmq(struct cs_etm_auxtrace *etm, { unsigned q,j; - if (/*(cpu < 0) ||*/ (0 == etm->queues.nr_queues)) + if (etm->queues.nr_queues == 0) return NULL; - if ((unsigned) cpu >= etm->queues.nr_queues) + if (cpu < 0) + q = 0; + else if ((unsigned) cpu >= etm->queues.nr_queues) q = etm->queues.nr_queues - 1; else q = cpu; |