From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 938601EF37D for ; Wed, 2 Apr 2025 11:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743592262; cv=none; b=mUqZai6di6gXPTU/VJ/EU0j5dvRFQFBq1WsR6ryjVWJMVaNy+LbK0GFHLBZr9m2cVPH0S0IjzzErpMgAH4+VaUu2nnZCL27Z2cvzbtswpXA+cfZ6zY9dP7Kn7YSnZnD8p5oSOYfHcdV6wA42EVXtii3MxXFdFVx2KYCOvlNopIE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743592262; c=relaxed/simple; bh=EWrgD18r2nfU1tBqbRK5IiJug7+Vse8FsJKY0eEvPCg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SPP6vF9Dqfewr7I0wEPmvCIgmHrt6oi0NhU4ksxtHUn+a4Lw455cw/pOkKs/KS+ROzHW8gOy+hK0EwGNL4RyobrsUW9xfBkgQkH7XnTeIBK4cbpfb2VBiRLIBSdQJ81fg1vVcH1sgYuRCutKg8lKMzCJf+T8rM4T19j1PGltu2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cLnfcCH4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cLnfcCH4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743592259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VgTSlcWUxY8a6JwJYyv7GJqNtqyp4QlKElc3qaVOgZs=; b=cLnfcCH4am2r9gPjcQePZzXFIuIAVDk8tlBrco5I4GXKwMabxdjxpbWuTUKDa5uP/H69y4 TXdilvHsw1lBoWVQXIFxnq1NES74LG+SVu6bjRQU9+DEd0KS5alttEbQkOc1SHZVSwOPw+ 5VRKZQnqL/GFA6VPD+FAurqua8eueso= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-xDKcHiZ4NxqXSrHBPqvjqA-1; Wed, 02 Apr 2025 07:10:56 -0400 X-MC-Unique: xDKcHiZ4NxqXSrHBPqvjqA-1 X-Mimecast-MFC-AGG-ID: xDKcHiZ4NxqXSrHBPqvjqA_1743592253 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 70F521809CA6; Wed, 2 Apr 2025 11:10:51 +0000 (UTC) Received: from f39 (unknown [10.45.225.130]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 738421828A80; Wed, 2 Apr 2025 11:10:25 +0000 (UTC) Date: Wed, 2 Apr 2025 13:10:22 +0200 From: Eder Zulian To: Ian Rogers Cc: Yury Norov , Rasmus Villemoes , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Jonathan Cameron , Nathan Chancellor , Bill Wendling , Justin Stitt , Josh Poimboeuf , Al Viro , Kyle Meyer , Ben Gainey , Athira Rajeev , Kajol Jain , Aditya Gupta , Dapeng Mi , Kuan-Wei Chiu , He Zhe , Dirk Gouders , Brian Geffon , Ravi Bangoria , Howard Chu , Charlie Jenkins , Colin Ian King , Dominique Martinet , Jann Horn , Masahiro Yamada , Arnd Bergmann , Yang Jihong , Dmitry Vyukov , Andi Kleen , Graham Woodward , Ilkka Koskinen , Anshuman Khandual , Zhongqiu Han , Hao Ge , Tengda Wu , Gabriele Monaco , Chun-Tse Shao , Casey Chen , "Dr. David Alan Gilbert" , Li Huafei , "Steinar H. Gunderson" , Levi Yun , Weilin Wang , Thomas Falcon , Thomas Richter , Andrew Kreimer , Krzysztof =?utf-8?Q?=C5=81opatowski?= , Christophe Leroy , Jean-Philippe Romain , Junhao He , "Masami Hiramatsu (Google)" , Xu Yang , Steve Clevenger , Zixian Cai , Stephen Brennan , Yujie Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [PATCH v1 04/48] x86/insn: Silence -Wshorten-64-to-32 warnings Message-ID: References: <20250401182347.3422199-1-irogers@google.com> <20250401182347.3422199-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250401182347.3422199-5-irogers@google.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Hello, apologies if I'm missing something, but On Tue, Apr 01, 2025 at 11:23:02AM -0700, Ian Rogers wrote: > The clang warning -Wshorten-64-to-32 can be useful to catch > inadvertent truncation. In some instances this truncation can lead to > changing the sign of a result, for example, truncation to return an > int to fit a sort routine. Silence the warning by making the implicit > truncation explicit. > > Signed-off-by: Ian Rogers > --- > tools/arch/x86/lib/insn.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/arch/x86/lib/insn.c b/tools/arch/x86/lib/insn.c > index e91d4c4e1c16..5fa8697498fe 100644 > --- a/tools/arch/x86/lib/insn.c > +++ b/tools/arch/x86/lib/insn.c > @@ -92,7 +92,7 @@ static int __insn_get_emulate_prefix(struct insn *insn, > goto err_out; > } > > - insn->emulate_prefix_size = len; > + insn->emulate_prefix_size = (int)len; wouldn't something like + insn->emulate_prefix_size = !!len; be preferable in this case? Apparently the 'insn->emulate_prefix_size' is only used in 'insn_has_emulate_prefix()'. Perhaps both the flag 'emulate_prefix_size' (currently an 'int') and the 'insn_has_emulate_prefix()' function return type could be changed to boolean? > insn->next_byte += len; My knowledge of this part of the code is limited, however IMO it seems strange to have the 'emulate_prefix_size' flag affected implictly or explicitly by truncation and the pointer 'insn->next_byte' advanced regardless. > > return 1; > -- > 2.49.0.504.g3bcea36a83-goog >