From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Tue, 10 Jun 2014 08:47:36 +0200 Subject: [U-Boot] [PATCH 2/3] usb:composite: clear the whole common buffer In-Reply-To: <1402320540-17058-3-git-send-email-jeroen@myspectrum.nl> References: <1402320540-17058-1-git-send-email-jeroen@myspectrum.nl> <1402320540-17058-3-git-send-email-jeroen@myspectrum.nl> Message-ID: <20140610084736.227a3eba@amdc2363> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > cc: Piotr Wilczek > cc: Kyungmin Park > cc: Marek Vasut > Signed-off-by: Jeroen Hofstee > --- > 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 -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group