[U-Boot] [PATCH 2/3] usb:composite: clear the whole common buffer

Lukasz Majewski l.majewski at samsung.com
Tue Jun 10 08:47:36 CEST 2014


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 at samsung.com>
> cc: Piotr Wilczek <p.wilczek at samsung.com>
> cc: Kyungmin Park <kyungmin.park at samsung.com>
> cc: Marek Vasut <marek.vasut at gmail.com>
> Signed-off-by: Jeroen Hofstee <jeroen at 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 at samsung.com>

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


More information about the U-Boot mailing list