* [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size
@ 2018-10-08 9:27 Bin Meng
2018-10-09 7:47 ` Miquel Raynal
2018-10-22 17:25 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 4+ messages in thread
From: Bin Meng @ 2018-10-08 9:27 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
drivers/mtd/nand/raw/atmel_nand.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/atmel_nand.c b/drivers/mtd/nand/raw/atmel_nand.c
index a5b76e1..31ad2cf 100644
--- a/drivers/mtd/nand/raw/atmel_nand.c
+++ b/drivers/mtd/nand/raw/atmel_nand.c
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size
2018-10-08 9:27 [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size Bin Meng
@ 2018-10-09 7:47 ` Miquel Raynal
2018-10-22 10:06 ` Bin Meng
2018-10-22 17:25 ` [U-Boot] " Tom Rini
1 sibling, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2018-10-09 7:47 UTC (permalink / raw)
To: u-boot
Hi Bin,
Bin Meng <bmeng.cn@gmail.com> wrote on Mon, 8 Oct 2018 02:27:44 -0700:
> 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.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
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.
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size
2018-10-09 7:47 ` Miquel Raynal
@ 2018-10-22 10:06 ` Bin Meng
0 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2018-10-22 10:06 UTC (permalink / raw)
To: u-boot
Hi Tom,
On Tue, Oct 9, 2018 at 3:47 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Hi Bin,
>
> Bin Meng <bmeng.cn@gmail.com> wrote on Mon, 8 Oct 2018 02:27:44 -0700:
>
> > 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.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
>
> 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.
>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
>
Will you take this for this release?
Regards,
Bin
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] nand: atmel: Initialize pmecc smu with correct size
2018-10-08 9:27 [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size Bin Meng
2018-10-09 7:47 ` Miquel Raynal
@ 2018-10-22 17:25 ` Tom Rini
1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2018-10-22 17:25 UTC (permalink / raw)
To: u-boot
On Mon, Oct 08, 2018 at 02:27:44AM -0700, Bin Meng wrote:
> 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.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Applied to u-boot/master, thanks!
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-22 17:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 9:27 [U-Boot] [PATCH] nand: atmel: Initialize pmecc smu with correct size Bin Meng
2018-10-09 7:47 ` Miquel Raynal
2018-10-22 10:06 ` Bin Meng
2018-10-22 17:25 ` [U-Boot] " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.