Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/xmon: replace sizeof calculations with ARRAY_SIZE macro

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

This patch replaces the sizeof calculations with the macro to make the
code cleaner and more immediately obvious what it is doing.

Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250719225225.2132-2-rubenru09@aol.com

authored by

Ruben Wauters and committed by
Madhavan Srinivasan
3d9c9e1d a3908790

+6 -10
+6 -10
arch/powerpc/xmon/ppc-opc.c
··· 954 954 { 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT }, 955 955 }; 956 956 957 - const unsigned int num_powerpc_operands = (sizeof (powerpc_operands) 958 - / sizeof (powerpc_operands[0])); 957 + const unsigned int num_powerpc_operands = ARRAY_SIZE(powerpc_operands); 959 958 960 959 /* The functions used to insert and extract complicated operands. */ 961 960 ··· 6967 6968 {"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}}, 6968 6969 }; 6969 6970 6970 - const int powerpc_num_opcodes = 6971 - sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]); 6972 - 6971 + const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes); 6972 + 6973 6973 /* The VLE opcode table. 6974 6974 6975 6975 The format of this opcode table is the same as the main opcode table. */ ··· 7205 7207 {"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}}, 7206 7208 }; 7207 7209 7208 - const int vle_num_opcodes = 7209 - sizeof (vle_opcodes) / sizeof (vle_opcodes[0]); 7210 - 7210 + const int vle_num_opcodes = ARRAY_SIZE(vle_opcodes); 7211 + 7211 7212 /* The macro table. This is only used by the assembler. */ 7212 7213 7213 7214 /* The expressions of the form (-x ! 31) & (x | 31) have the value 0 ··· 7273 7276 {"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"}, 7274 7277 }; 7275 7278 7276 - const int powerpc_num_macros = 7277 - sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); 7279 + const int powerpc_num_macros = ARRAY_SIZE(powerpc_macros);