diff mbox series

[v3,5/5] perf cs-etm: Fix unsigned variable comparison to zero

Message ID 20200203015203.27882-6-leo.yan@linaro.org (mailing list archive)
State New, archived
Headers show
Series perf cs-etm: Fix synthesizing instruction samples | expand

Commit Message

Leo Yan Feb. 3, 2020, 1:52 a.m. UTC
The variable 'offset' in function cs_etm__sample() is u64 type, it's not
appropriate to check it with 'while (offset > 0)'; this patch changes to
'while (offset)'.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/util/cs-etm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Leach Feb. 6, 2020, 11:48 a.m. UTC | #1
Reviewed by: Mike Leach <mike.leach@linaro.org>

On Mon, 3 Feb 2020 at 01:53, Leo Yan <leo.yan@linaro.org> wrote:
>
> The variable 'offset' in function cs_etm__sample() is u64 type, it's not
> appropriate to check it with 'while (offset > 0)'; this patch changes to
> 'while (offset)'.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>  tools/perf/util/cs-etm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index dbddf1eec2be..720108bd8dba 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -945,7 +945,7 @@ static inline u64 cs_etm__instr_addr(struct cs_etm_queue *etmq,
>         if (packet->isa == CS_ETM_ISA_T32) {
>                 u64 addr = packet->start_addr;
>
> -               while (offset > 0) {
> +               while (offset) {
>                         addr += cs_etm__t32_instr_size(etmq,
>                                                        trace_chan_id, addr);
>                         offset--;
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index dbddf1eec2be..720108bd8dba 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -945,7 +945,7 @@  static inline u64 cs_etm__instr_addr(struct cs_etm_queue *etmq,
 	if (packet->isa == CS_ETM_ISA_T32) {
 		u64 addr = packet->start_addr;
 
-		while (offset > 0) {
+		while (offset) {
 			addr += cs_etm__t32_instr_size(etmq,
 						       trace_chan_id, addr);
 			offset--;