From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sonic.asd.mail.yahoo.com (sonic301-22.consmr.mail.gq1.yahoo.com [98.137.64.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 399A9142E67 for ; Thu, 31 Jul 2025 17:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=98.137.64.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753983045; cv=none; b=BvQ0BOYiplMgkJa5VDmitEdG1rdfHvj0kPXrpO5FumMz9ej+wtkRkxv6gtIBet8W1feHE1xDdOKLXu+VqQWULj7U6W2Bz36qH07QGo/ByDbYzRMUfwrauddsOs+PKiBoABCbxg07kv0VqaA2xX5tEqtGP5YsVAqINGvFYKpzHwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753983045; c=relaxed/simple; bh=iMnATmascgGeczYNNRglDU5ZHw3NEt2KENIz1qbn3Q8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=pr+pwWh+CinbFkZ8z57dNjlnPd9Lb9sanRHfPQ09UxlP6Ro9hEo2ebnOFkReWHiiZ+Kgyqyjo5QfQfFMutmWbtx/b5pU6+WWmSO6NWMVWR+2jNLE0AlmzTa6K6/79QXZHn+n5Asb/LVYhKH6dIbkM60atiBn5+Mz1z29jCkMPCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aol.com; spf=pass smtp.mailfrom=aol.com; dkim=pass (2048-bit key) header.d=aol.com header.i=@aol.com header.b=rohotRgQ; arc=none smtp.client-ip=98.137.64.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=aol.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aol.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=aol.com header.i=@aol.com header.b="rohotRgQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1753983043; bh=iMnATmascgGeczYNNRglDU5ZHw3NEt2KENIz1qbn3Q8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From:Subject:Reply-To; b=rohotRgQ9uHqDac4yYnMb0e6eZrqgK4bgypkgEYce6lFSJEBW6YEelcObqoUOJKSstpAwhwZts6HPWS317UiAPoJ2aaChQm71VMeYuW2dMVgDVW4gQTySiVDq28M5xTOMLBWFf2V8K3SzfcCN4XpeJvUQnauUxMEotMA2lYLUrpJOSmwYqdoHOm+1AZt3zWdEiLyGrWi4UXtmaiATTFrVaa9aLgB2X/7WdAuTOdQJzcTFhLc7tZgdUaZiuFACT7veA8BVWjlf67FRGxTkAmsIvRaXt8uKdQs6E4pA1KaGj6NHoN9MYxdMirGCAoMpRnXuMqjU2YNfpdfZ6eSXonUug== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1753983043; bh=OYSG3+OXV61S1zLYZ/eN9S3JbsSOt1KEeE/Gun/4mtS=; h=X-Sonic-MF:Subject:From:To:Date:From:Subject; b=ZcCO7/orVOOKKS/8OU2zzYiOKYI77S/3m6pGoBW8lF0i1ARwJbvzMeH+fn4Vro+K3kNmyF3evvXV65tjv3ccW+/6+rQq+Wk4nqgyJATdD20JijlW/AKKx+k912eHiEjuwGTmMx94xmkFCSxWIVOWErOCDrc1ZV4rCVh8A6u1ItKT/y0yHmKhmhxJ00ojhRhtvr55UJrwbZqItfIhnn737DUMT08A+ACq1lJuNdvl1e7I2GrR8X23gFGF5q56EhEnAVSawciFeFf6EZkr2RLnEXkGoBsk1ISHvAIzJdRGPhc4sKLDSkcTn0pMcn6aFVC8scg9DTf1dcizEJwL/JcMbA== X-YMail-OSG: kgh7gwoVM1mpHEWZyKNv4B1Nlw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rZlxRvj3R0uH7iLN2cr6qXyBPIl8wz K3q6JCMHRPRVrc69QMJSTtuqtduxzcNUKKMCzZeSikDhKbLeLmwfVabuihqOYedY9s5RnhOW8wIl d_7kx6A-- X-Sonic-MF: X-Sonic-ID: a36ced8b-cb9a-42a8-bef4-8460bcebc97d Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.gq1.yahoo.com with HTTP; Thu, 31 Jul 2025 17:30:43 +0000 Received: by hermes--production-ir2-858bd4ff7b-9r9sx (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID d00c2078b76ee3e43b9910e86da44ded; Thu, 31 Jul 2025 16:40:07 +0000 (UTC) Message-ID: <8381a142d72f3cd0e92de4dac6acfc0241a87365.camel@aol.com> Subject: Re: [PATCH] powerpc/xmon: replace sizeof calculations with ARRAY_SIZE macro From: Ruben Wauters To: Christophe Leroy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Thu, 31 Jul 2025 17:40:05 +0100 In-Reply-To: <62aa5231-ed31-43e2-84b7-d6b6ec86e78d@csgroup.eu> References: <20250719225225.2132-2-rubenru09.ref@aol.com> <20250719225225.2132-2-rubenru09@aol.com> <62aa5231-ed31-43e2-84b7-d6b6ec86e78d@csgroup.eu> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: WebService/1.1.24260 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol On Wed, 2025-07-30 at 08:14 +0200, Christophe Leroy wrote: >=20 >=20 > Le 20/07/2025 =C3=A0 00:43, Ruben Wauters a =C3=A9crit=C2=A0: > > [Vous ne recevez pas souvent de courriers de rubenru09@aol.com. > > D=C3=A9couvrez pourquoi ceci est important =C3=A0 > > https://aka.ms/LearnAboutSenderIdentification=C2=A0] > >=20 > > The calculations for operand/opcode/macro numbers are done in an > > identical manner to the already existing ARRAY_SIZE macro in > > linux/array_size.h > >=20 > > This patch replaces the sizeof calculations with the macro to make > > the > > code cleaner and more immediately obvious what it is doing. > >=20 > > Signed-off-by: Ruben Wauters > > --- > > =C2=A0 arch/powerpc/xmon/ppc-opc.c | 16 ++++++---------- >=20 > This file is mostly taken from binutils, refer commit 08d96e0b127e=20 > ("powerpc/xmon: Apply binutils changes to upgrade disassembly"). >=20 > I think your change should be done in binutils then backported to the > kernel. The more we diverge from binutils the worse it is While this is somewhat reasonable, the header (linux/array_size.h) is linux specific, and is included through kernel.h I can probably see if binutils has a similar header, or if they would accept an equivalent header to make the file equivalent, but I'm unsure if they would Ruben > Christophe >=20 >=20 > > =C2=A0 1 file changed, 6 insertions(+), 10 deletions(-) > >=20 > > diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc- > > opc.c > > index 0774d711453e..de9b4236728c 100644 > > --- a/arch/powerpc/xmon/ppc-opc.c > > +++ b/arch/powerpc/xmon/ppc-opc.c > > @@ -954,8 +954,7 @@ const struct powerpc_operand powerpc_operands[] > > =3D > > =C2=A0=C2=A0=C2=A0 { 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT }, > > =C2=A0 }; > >=20 > > -const unsigned int num_powerpc_operands =3D (sizeof > > (powerpc_operands) > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 / sizeof > > (powerpc_operands[0])); > > +const unsigned int num_powerpc_operands =3D > > ARRAY_SIZE(powerpc_operands); > >=20 > > =C2=A0 /* The functions used to insert and extract complicated > > operands.=C2=A0 */ > >=20 > > @@ -6968,9 +6967,8 @@ const struct powerpc_opcode powerpc_opcodes[] > > =3D { > > =C2=A0 {"fcfidu.",=C2=A0=C2=A0=C2=A0 XRC(63,974,1),=C2=A0 XRA_MASK, POW= ER7|PPCA2, > > PPCVLE,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 {FRT, FRB}}, > > =C2=A0 }; > >=20 > > -const int powerpc_num_opcodes =3D > > -=C2=A0 sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]); > > - > > +const int powerpc_num_opcodes =3D ARRAY_SIZE(powerpc_opcodes); > > + > > =C2=A0 /* The VLE opcode table. > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0 The format of this opcode table is the same as= the main opcode > > table.=C2=A0 */ > > @@ -7207,9 +7205,8 @@ const struct powerpc_opcode vle_opcodes[] =3D { > > =C2=A0 {"se_bl",=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BD8(58,0,1),=C2=A0=C2=A0= =C2=A0 BD8_MASK,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PPCVLE, > > 0,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 {B8}}, > > =C2=A0 }; > >=20 > > -const int vle_num_opcodes =3D > > -=C2=A0 sizeof (vle_opcodes) / sizeof (vle_opcodes[0]); > > - > > +const int vle_num_opcodes =3D ARRAY_SIZE(vle_opcodes); > > + > > =C2=A0 /* The macro table.=C2=A0 This is only used by the assembler.=C2= =A0 */ > >=20 > > =C2=A0 /* The expressions of the form (-x ! 31) & (x | 31) have the > > value 0 > > @@ -7276,5 +7273,4 @@ const struct powerpc_macro powerpc_macros[] =3D > > { > > =C2=A0 {"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"}, > > =C2=A0 }; > >=20 > > -const int powerpc_num_macros =3D > > -=C2=A0 sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); > > +const int powerpc_num_macros =3D ARRAY_SIZE(powerpc_macros); > > -- > > 2.49.1 > >=20