Message ID | 20230406135840.1529325-1-trini@konsulko.com |
---|---|
State | Accepted |
Commit | e97c89cc15b90c72dcf6a7a943fb52743a1f70fa |
Delegated to: | Tom Rini |
Headers | show |
Series | qemu: dfu: Correct memset call in set_dfu_alt_info | expand |
On Fri, 7 Apr 2023 at 01:58, Tom Rini <trini@konsulko.com> wrote: > > When building with clang, we see: > board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess] > > As we're calling memset with the length set to the size of the pointer > and not the size of the buffer. Correct this with a call of the size of > the buffer itself. > > Signed-off-by: Tom Rini <trini@konsulko.com> > --- > Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> > Cc: Sughosh Ganu <sughosh.ganu@linaro.org> > Cc: Simon Glass <sjg@chromium.org> > --- > board/emulation/common/qemu_dfu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Simon Glass <sjg@chromium.org>
On Thu, 6 Apr 2023 at 19:28, Tom Rini <trini@konsulko.com> wrote: > > When building with clang, we see: > board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess] > > As we're calling memset with the length set to the size of the pointer > and not the size of the buffer. Correct this with a call of the size of > the buffer itself. > > Signed-off-by: Tom Rini <trini@konsulko.com> > --- Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> -sughosh > Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> > Cc: Sughosh Ganu <sughosh.ganu@linaro.org> > Cc: Simon Glass <sjg@chromium.org> > --- > board/emulation/common/qemu_dfu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/board/emulation/common/qemu_dfu.c b/board/emulation/common/qemu_dfu.c > index 332d659c1f7c..7e7d84f6c00f 100644 > --- a/board/emulation/common/qemu_dfu.c > +++ b/board/emulation/common/qemu_dfu.c > @@ -48,7 +48,7 @@ void set_dfu_alt_info(char *interface, char *devstr) > env_get("dfu_alt_info")) > return; > > - memset(buf, 0, sizeof(buf)); > + memset(buf, 0, DFU_ALT_BUF_LEN); > > /* > * Currently dfu_alt_info is needed on Qemu ARM64 for > -- > 2.34.1 >
On Thu, Apr 06, 2023 at 09:58:40AM -0400, Tom Rini wrote: > When building with clang, we see: > board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess] > > As we're calling memset with the length set to the size of the pointer > and not the size of the buffer. Correct this with a call of the size of > the buffer itself. > > Signed-off-by: Tom Rini <trini@konsulko.com> > Reviewed-by: Simon Glass <sjg@chromium.org> > Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Applied to u-boot/master, thanks!
diff --git a/board/emulation/common/qemu_dfu.c b/board/emulation/common/qemu_dfu.c index 332d659c1f7c..7e7d84f6c00f 100644 --- a/board/emulation/common/qemu_dfu.c +++ b/board/emulation/common/qemu_dfu.c @@ -48,7 +48,7 @@ void set_dfu_alt_info(char *interface, char *devstr) env_get("dfu_alt_info")) return; - memset(buf, 0, sizeof(buf)); + memset(buf, 0, DFU_ALT_BUF_LEN); /* * Currently dfu_alt_info is needed on Qemu ARM64 for
When building with clang, we see: board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess] As we're calling memset with the length set to the size of the pointer and not the size of the buffer. Correct this with a call of the size of the buffer itself. Signed-off-by: Tom Rini <trini@konsulko.com> --- Cc: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi> Cc: Sughosh Ganu <sughosh.ganu@linaro.org> Cc: Simon Glass <sjg@chromium.org> --- board/emulation/common/qemu_dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)