Skip to contentSkip to conversation

nand: atmel: Initialize pmecc smu with correct size

PATCH In review Bin Meng 3 participants 4 messages Oct 8, 2018 – Oct 22, 2018

Subsystems (3)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 nand: atmel: Initialize pmecc smu with correct size

Currently in pmecc_get_sigma(), the code tries to clear the memory pointed by smu with wrong size 'sizeof(int16_t) * ARRAY_SIZE(smu)'. Since smu is actually a pointer, not an array, so ARRAY_SIZE(smu) does not generate correct size to be cleared.

In fact, GCC 8.1.0 reports a warning against it:

error: division 'sizeof (int16_t * {aka short int *}) / sizeof (int16_t {aka short int})' does not compute the number of array elements [-Werror=sizeof-pointer-div]

Fix it by using the correct size.

---

 drivers/mtd/nand/raw/atmel_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/atmel_nand.c +1 -1
index a5b76e1..31ad2cf 100644
@@ -249,7 +249,7 @@ static void pmecc_get_sigma(struct mtd_info *mtd)
 	int diff;
 
 	/* Init the Sigma(x) */
-	memset(smu, 0, sizeof(int16_t) * ARRAY_SIZE(smu));
+	memset(smu, 0, sizeof(int16_t) * num * (cap + 2));
 
 	dmu_0_count = 0;
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

PATCH 1/1 nand: atmel: Initialize pmecc smu with correct size

Hi Bin,

Bin Meng <[email protected]> wrote on Mon, 8 Oct 2018 02:27:44 -0700:

Quoted 7 lines

Currently in pmecc_get_sigma(), the code tries to clear the memory pointed by smu with wrong size 'sizeof(int16_t) * ARRAY_SIZE(smu)'. Since smu is actually a pointer, not an array, so ARRAY_SIZE(smu) does not generate correct size to be cleared.

In fact, GCC 8.1.0 reports a warning against it:

Quoted 9 lines

error: division 'sizeof (int16_t * {aka short int *}) / sizeof (int16_t {aka short int})' does not compute the number of array elements [-Werror=sizeof-pointer-div]

Fix it by using the correct size.

---

It's curious that the code of this driver differs a lot from its Linux cousin. Anyway this looks fine by me. Maybe a Fixes tag would be great.

Thanks,
Miquèl

author
#2 lore raw

PATCH 1/1 nand: atmel: Initialize pmecc smu with correct size

Hi Tom,

Quoted 22 lines · Miquel Raynal

Hi Bin,

Bin Meng <[email protected]> wrote on Mon, 8 Oct 2018 02:27:44 -0700:

Quoted 7 lines

Currently in pmecc_get_sigma(), the code tries to clear the memory pointed by smu with wrong size 'sizeof(int16_t) * ARRAY_SIZE(smu)'. Since smu is actually a pointer, not an array, so ARRAY_SIZE(smu) does not generate correct size to be cleared.

In fact, GCC 8.1.0 reports a warning against it:

Quoted 9 lines

error: division 'sizeof (int16_t * {aka short int *}) / sizeof (int16_t {aka short int})' does not compute the number of array elements [-Werror=sizeof-pointer-div]

Fix it by using the correct size.

---

Quoted 6 lines

It's curious that the code of this driver differs a lot from its Linux cousin. Anyway this looks fine by me. Maybe a Fixes tag would be great.

Will you take this for this release?

Regards,
Bin

#3 lore raw
In reply to Bin Meng
Quoted 7 lines · Bin Meng

Currently in pmecc_get_sigma(), the code tries to clear the memory pointed by smu with wrong size 'sizeof(int16_t) * ARRAY_SIZE(smu)'. Since smu is actually a pointer, not an array, so ARRAY_SIZE(smu) does not generate correct size to be cleared.

In fact, GCC 8.1.0 reports a warning against it:

Quoted 8 lines

error: division 'sizeof (int16_t * {aka short int *}) / sizeof (int16_t {aka short int})' does not compute the number of array elements [-Werror=sizeof-pointer-div]

Fix it by using the correct size.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181022/87e0ef08/attachment.sig>