From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] usb:composite: clear the whole common buffer
Date: Tue, 10 Jun 2014 08:47:36 +0200 [thread overview]
Message-ID: <20140610084736.227a3eba@amdc2363> (raw)
In-Reply-To: <1402320540-17058-3-git-send-email-jeroen@myspectrum.nl>
Hi Jeroen,
> Since the struct fsg_common is calloced, reset it completely
> with zero's when reused. While at it, make checkpatch happy.
>
> cc: Lukasz Majewski <l.majewski@samsung.com>
> cc: Piotr Wilczek <p.wilczek@samsung.com>
> cc: Kyungmin Park <kyungmin.park@samsung.com>
> cc: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
> ---
> drivers/usb/gadget/f_mass_storage.c:2470:28: warning: 'memset' call
> operates on objects of type 'struct fsg_common' while the size is
> based on a different type 'struct fsg_common
> *' [-Wsizeof-pointer-memaccess] memset(common, 0, sizeof common);
>
> Note: There is another warning worth mentioning, but I don't
> know what the correct behaviour should be.
>
> drivers/usb/gadget/f_mass_storage.c:1153:6: warning: variable
> 'sdinfo' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized] if (!curlun) { /* Unsupported
> LUNs are okay */ ^~~~~~~
> drivers/usb/gadget/f_mass_storage.c:1168:21: note: uninitialized use
> occurs here put_unaligned_be32(sdinfo, &buf[3]); /* Sense
> information */ ---
> drivers/usb/gadget/f_mass_storage.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c index 6374bb9..f274d96 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2462,12 +2462,12 @@ static struct fsg_common
> *fsg_common_init(struct fsg_common *common,
> /* Allocate? */
> if (!common) {
> - common = calloc(sizeof *common, 1);
> + common = calloc(sizeof(*common), 1);
> if (!common)
> return ERR_PTR(-ENOMEM);
> common->free_storage_on_release = 1;
> } else {
> - memset(common, 0, sizeof common);
> + memset(common, 0, sizeof(*common));
> common->free_storage_on_release = 0;
> }
>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
next prev parent reply other threads:[~2014-06-10 6:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-09 13:28 [U-Boot] [PATCH 0/3] fix clang warnings about sizeof usage Jeroen Hofstee
2014-06-09 13:28 ` [U-Boot] [PATCH 1/3] usb:g_dnl:f_thor: remove memset before memcpy Jeroen Hofstee
2014-06-10 6:50 ` Lukasz Majewski
2014-06-09 13:28 ` [U-Boot] [PATCH 2/3] usb:composite: clear the whole common buffer Jeroen Hofstee
2014-06-09 17:59 ` Marek Vasut
2014-06-10 6:47 ` Lukasz Majewski [this message]
2014-06-09 13:29 ` [U-Boot] [PATCH 3/3] ext4: correctly zero filename Jeroen Hofstee
2014-06-09 17:58 ` Marek Vasut
2014-06-11 22:19 ` [U-Boot] [U-Boot,3/3] " Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140610084736.227a3eba@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.