From patchwork Sat Oct 5 09:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 175261 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1790707ill; Sat, 5 Oct 2019 02:16:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwVIXlj3fLg0pMmhYlj6J6i/Xz3QuYVwVZ4BueUtxZAL7cFI20CY0xDl7eLLMiAlqtw+iT X-Received: by 2002:a17:906:2cc8:: with SMTP id r8mr15990757ejr.197.1570267005865; Sat, 05 Oct 2019 02:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570267005; cv=none; d=google.com; s=arc-20160816; b=xMZiZ0No+oQ/SX1bUw9N8EJBHEbQyiYDjOs2OTy/jTW/gG+EuD+lvIKRzGytrigLYG wT6koB+w3f9iaRZvHWf1fOHOGK86OicddXwe8KpXaDQTcK3XlXQ26r1Gr2EkU/aAqrym kbpuXvl1FXVJ+tEBBLiG6DtBlpD3fAU7CiLWq5Go5mCU+7D6EZwL7jdwmKrOytT6NyZ9 MqZbz3ziAyQDiMK90OiLfmy1b8CI9lyCU8u5KF7EfFClmh3iozO2mE30T0UpL8Oyakqr v4WSSRj5LibXSh28GAKyCE4mBGnb/W3MIV9YSlpIgTw+bXKxScBqMMHJ5VtxWFW8P29r ytzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=5GP/KNw0NThi+xFyZyJwWXss0a8iqQMvGrS8dpQzhPU=; b=WiMMspqgWL7IWKTBJUv112n1/BO4Zm/yrAYC4b3oy9pVi3jzLeDbquHc+whnYkvLh4 4MS66PblB+eG7AKU/lmI5B6O6Jyn6vSld3F1fsYQrVs+wDGYp7RRMUrXrs2cAfHsbITt i5MC81A31ZwYehTKeK87vWxzk8kLcUvYE/Ntt8oi4I3Bmfyqqw57Er8IV10rzSkfUX74 MZmN43jnt2vF2veOPjT80FFEHb+ujHCogz2rTtdKIjDayMu38P+uLR3Vdp8ouXvMjnzL uQ20Mo4V7Tfi+dVog1qoMsVyl/i1oM4UVXPb0Z+8JAdI40m9WlvQtx6yx0yNUo8zYx+U W5TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SEchh8dj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b30si5070907eda.200.2019.10.05.02.16.45; Sat, 05 Oct 2019 02:16:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SEchh8dj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727597AbfJEJQm (ORCPT + 27 others); Sat, 5 Oct 2019 05:16:42 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:38819 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfJEJQk (ORCPT ); Sat, 5 Oct 2019 05:16:40 -0400 Received: by mail-qt1-f196.google.com with SMTP id j31so12167934qta.5 for ; Sat, 05 Oct 2019 02:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5GP/KNw0NThi+xFyZyJwWXss0a8iqQMvGrS8dpQzhPU=; b=SEchh8dj4qcptxwJcOAo15ZrP0Q38g28a7exn9iyxXlFmNigonCzvKJmR+iRVs6LuZ pe8vklnaBfIYulObSewcnQQrqBuQJxJ/I2cyRFnh6KS/FnGui180xTOP+SyKzW1iYnlj b8+1/rcEni7xHn3+XNgwn8KKOMfaJMNhwG+nOI08nLatBTQSM5ZkymsT7UYadFZ2DsSN MvNrj0HDFMuVxFYIEnrKrucUC0Hh0WP5clNjK8Kgi1JpHRsbonXOoluIQqsOgn6FecLj rr+pjsUMIgoJfiL40lAgaeKoosOETz0+sdryR0vpnXdwZxjelYcPk80c9bX0jldErFH5 4+cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5GP/KNw0NThi+xFyZyJwWXss0a8iqQMvGrS8dpQzhPU=; b=qm9887M119pU+19NlEY3k2TOjpZgOB5g4BSE0WY0w9DRYKYIIY8/b10BAKgRFoKH1B Tk4LsxmebRohaEZzF2Joj99k+dhg0Ssz4buRghuhcStNwmjaYFL3wzEhJXUa7Fa7bHt7 /r/a6LaeBv+p1PQwETYGyEC+uBHCd2UkOL/qkTmBbUClf+ElImngAUGa4CuXFGtPji4Q Jquf9eVAdFDaZKqa8NT2X+dMaS0NxMxuJCpChaPLwLSzzeLkb7xnF0bdwi4jsZcEvmr6 amkn8uGGbokckFU9YUeyxINlBrlzVT8XjgqB+TsyVfhZB+jn4vjAl7egM39ZsBr3V9PR 3RSQ== X-Gm-Message-State: APjAAAXXR9sYoyF0kQZrM8mEysA0bIGV4cIimK+G3/obwTpHell+hi/W u0VwF89LgYxZQ6YhcUC6SRnDDQ== X-Received: by 2002:ac8:1701:: with SMTP id w1mr20870585qtj.24.1570266999647; Sat, 05 Oct 2019 02:16:39 -0700 (PDT) Received: from localhost.localdomain (li937-157.members.linode.com. [45.56.119.157]) by smtp.gmail.com with ESMTPSA id u132sm4384621qka.50.2019.10.05.02.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2019 02:16:39 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Mathieu Poirier , Suzuki K Poulose , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mike Leach , Coresight ML , Peter Zijlstra , Ingo Molnar Cc: Leo Yan Subject: [PATCH v3 1/6] perf cs-etm: Fix unsigned variable comparison to zero Date: Sat, 5 Oct 2019 17:16:09 +0800 Message-Id: <20191005091614.11635-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191005091614.11635-1-leo.yan@linaro.org> References: <20191005091614.11635-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the u64 variable 'offset' is a negative integer, comparison it with bigger than zero is always going to be true because it is unsigned. Fix this by using s64 type for variable 'offset'. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 4ba0f871f086..4bc2d9709d4f 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -940,7 +940,7 @@ u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet) static inline u64 cs_etm__instr_addr(struct cs_etm_queue *etmq, u64 trace_chan_id, const struct cs_etm_packet *packet, - u64 offset) + s64 offset) { if (packet->isa == CS_ETM_ISA_T32) { u64 addr = packet->start_addr; @@ -1372,7 +1372,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq, * sample is reported as though instruction has just been * executed, but PC has not advanced to next instruction) */ - u64 offset = (instrs_executed - instrs_over - 1); + s64 offset = (instrs_executed - instrs_over - 1); u64 addr = cs_etm__instr_addr(etmq, trace_chan_id, tidq->packet, offset);