Skip to contentSkip to conversation

mtd: rawnand: ingenic: cleanup ARRAY_SIZE() vs sizeof() use

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 24, 2020 – Jul 7, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: ingenic: cleanup ARRAY_SIZE() vs sizeof() use

The ARRAY_SIZE() is the number of elements but we want to use sizeof() here for the number of bytes. Fortunately, they are the same thing because it's an array of u8 so this has no effect on runtime.

---
 drivers/mtd/nand/raw/ingenic/jz4740_ecc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/ingenic/jz4740_ecc.c +2 -2
index 13fea645c7f0..54e377754a6c 100644
@@ -90,8 +90,8 @@ static int jz4740_ecc_calculate(struct ingenic_ecc *ecc,
 	 * If the written data is completely 0xff, we also want to write 0xff as
 	 * ECC, otherwise we will get in trouble when doing subpage writes.
 	 */
-	if (memcmp(ecc_code, empty_block_ecc, ARRAY_SIZE(empty_block_ecc)) = 0)
-		memset(ecc_code, 0xff, ARRAY_SIZE(empty_block_ecc));
+	if (memcmp(ecc_code, empty_block_ecc, sizeof(empty_block_ecc)) = 0)
+		memset(ecc_code, 0xff, sizeof(empty_block_ecc));
 
 	return 0;
 }
Signature · 1 line
2.27.0