drivers: macintosh: rack-meter: really fix bogus memsets
diff mbox series

Message ID 20180316201728.3377-1-aaro.koskinen@iki.fi
State Accepted
Commit e283655b5abe26462d53d5196f186c5e8863af3b
Headers show
Series
  • drivers: macintosh: rack-meter: really fix bogus memsets
Related show

Commit Message

Aaro Koskinen March 16, 2018, 8:17 p.m. UTC
We should zero an array using sizeof instead of number of elements.

Fixes the following compiler (GCC 7.3.0) warnings:

drivers/macintosh/rack-meter.c: In function 'rackmeter_do_pause':
drivers/macintosh/rack-meter.c:157:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
drivers/macintosh/rack-meter.c:158:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

Fixes: 4f7bef7a9f69 ("drivers: macintosh: rack-meter: fix bogus memsets")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 drivers/macintosh/rack-meter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Ellerman March 31, 2018, 2:03 p.m. UTC | #1
On Fri, 2018-03-16 at 20:17:28 UTC, Aaro Koskinen wrote:
> We should zero an array using sizeof instead of number of elements.
> 
> Fixes the following compiler (GCC 7.3.0) warnings:
> 
> drivers/macintosh/rack-meter.c: In function 'rackmeter_do_pause':
> drivers/macintosh/rack-meter.c:157:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> drivers/macintosh/rack-meter.c:158:2: warning: 'memset' used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> 
> Fixes: 4f7bef7a9f69 ("drivers: macintosh: rack-meter: fix bogus memsets")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/e283655b5abe26462d53d5196f186c

cheers

Patch
diff mbox series

diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index 910b5b6..eb65b6e 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -154,8 +154,8 @@  static void rackmeter_do_pause(struct rackmeter *rm, int pause)
 		DBDMA_DO_STOP(rm->dma_regs);
 		return;
 	}
-	memset(rdma->buf1, 0, ARRAY_SIZE(rdma->buf1));
-	memset(rdma->buf2, 0, ARRAY_SIZE(rdma->buf2));
+	memset(rdma->buf1, 0, sizeof(rdma->buf1));
+	memset(rdma->buf2, 0, sizeof(rdma->buf2));
 
 	rm->dma_buf_v->mark = 0;