linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning
@ 2015-07-14  1:48 Chaehyun Lim
  2015-07-14  1:48 ` [PATCH 2/2] staging: wilc1000: fix memory allocation error check Chaehyun Lim
  2015-07-14  2:32 ` [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Julian Calaby
  0 siblings, 2 replies; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-14  1:48 UTC (permalink / raw)
  To: gregkh
  Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
	devel, Chaehyun Lim

When building this driver, I got a warning as below:

host_interface.c: In function ‘host_int_add_beacon’:
host_interface.c:7116:16: warning: ‘*((void *)&strHostIFmsg+8).pu8Head’ may be used
uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
 drivers/staging/wilc1000/host_interface.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index c089e73..ca97b70 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -7131,8 +7131,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
 	pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
 	pstrSetBeaconParam->u32HeadLen = u32HeadLen;
 	pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
-	if (pstrSetBeaconParam->pu8Head == NULL)
-		WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+	if (pstrSetBeaconParam->pu8Head == NULL) {
+		PRINT_ER("Failed to allocated memory\n");
+		s32Error = WILC_NO_MEM;
+		goto _fail_;
+	}
 	WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
 	pstrSetBeaconParam->u32TailLen = u32TailLen;
 
@@ -7159,6 +7162,7 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
 			WILC_FREE(pstrSetBeaconParam->pu8Tail);
 	}
 
+_fail_:
 	return s32Error;
 
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] staging: wilc1000: fix memory allocation error check
  2015-07-14  1:48 [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Chaehyun Lim
@ 2015-07-14  1:48 ` Chaehyun Lim
  2015-07-14 21:16   ` Greg KH
  2015-07-14  2:32 ` [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Julian Calaby
  1 sibling, 1 reply; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-14  1:48 UTC (permalink / raw)
  To: gregkh
  Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
	devel, Chaehyun Lim

Remove WILC_ERRORREPORT macro. If memory allocation is failed,
jump to a label to return this function with WILC_NO_MEM.

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
 drivers/staging/wilc1000/host_interface.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index ca97b70..f6ba7d1 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -7142,8 +7142,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
 	/* Bug 4599 : if tail length = 0 skip allocating & copying */
 	if (u32TailLen > 0) {
 		pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
-		if (pstrSetBeaconParam->pu8Tail == NULL)
-			WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+		if (pstrSetBeaconParam->pu8Tail == NULL) {
+			PRINT_ER("Failed to allocate memory\n");
+			s32Error = WILC_NO_MEM;
+			goto _fail_;
+		}
 		WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
 	} else {
 		pstrSetBeaconParam->pu8Tail = NULL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning
  2015-07-14  1:48 [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Chaehyun Lim
  2015-07-14  1:48 ` [PATCH 2/2] staging: wilc1000: fix memory allocation error check Chaehyun Lim
@ 2015-07-14  2:32 ` Julian Calaby
  1 sibling, 0 replies; 6+ messages in thread
From: Julian Calaby @ 2015-07-14  2:32 UTC (permalink / raw)
  To: Chaehyun Lim
  Cc: Greg KH, Johnny Kim, Rachel Kim, Dean Lee, Chris Park,
	linux-wireless, devel@driverdev.osuosl.org

Hi Chaehyun,

On Tue, Jul 14, 2015 at 11:48 AM, Chaehyun Lim <chaehyun.lim@gmail.com> wrote:
> When building this driver, I got a warning as below:
>
> host_interface.c: In function ‘host_int_add_beacon’:
> host_interface.c:7116:16: warning: ‘*((void *)&strHostIFmsg+8).pu8Head’ may be used
> uninitialized in this function [-Wmaybe-uninitialized]
>
> Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> ---
>  drivers/staging/wilc1000/host_interface.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
> index c089e73..ca97b70 100644
> --- a/drivers/staging/wilc1000/host_interface.c
> +++ b/drivers/staging/wilc1000/host_interface.c
> @@ -7131,8 +7131,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
>         pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
>         pstrSetBeaconParam->u32HeadLen = u32HeadLen;
>         pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
> -       if (pstrSetBeaconParam->pu8Head == NULL)
> -               WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
> +       if (pstrSetBeaconParam->pu8Head == NULL) {
> +               PRINT_ER("Failed to allocated memory\n");
> +               s32Error = WILC_NO_MEM;
> +               goto _fail_;

Why not just return WILC_NO_MEM here instead of jumping to the return below?

> +       }
>         WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
>         pstrSetBeaconParam->u32TailLen = u32TailLen;
>
> @@ -7159,6 +7162,7 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
>                         WILC_FREE(pstrSetBeaconParam->pu8Tail);
>         }
>
> +_fail_:
>         return s32Error;
>
>  }

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] staging: wilc1000: fix memory allocation error check
  2015-07-14  1:48 ` [PATCH 2/2] staging: wilc1000: fix memory allocation error check Chaehyun Lim
@ 2015-07-14 21:16   ` Greg KH
  2015-07-14 23:14     ` Chaehyun Lim
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2015-07-14 21:16 UTC (permalink / raw)
  To: Chaehyun Lim
  Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
	devel

On Tue, Jul 14, 2015 at 10:48:41AM +0900, Chaehyun Lim wrote:
> Remove WILC_ERRORREPORT macro. If memory allocation is failed,
> jump to a label to return this function with WILC_NO_MEM.
> 
> Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> ---
>  drivers/staging/wilc1000/host_interface.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
> index ca97b70..f6ba7d1 100644
> --- a/drivers/staging/wilc1000/host_interface.c
> +++ b/drivers/staging/wilc1000/host_interface.c
> @@ -7142,8 +7142,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
>  	/* Bug 4599 : if tail length = 0 skip allocating & copying */
>  	if (u32TailLen > 0) {
>  		pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
> -		if (pstrSetBeaconParam->pu8Tail == NULL)
> -			WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
> +		if (pstrSetBeaconParam->pu8Tail == NULL) {
> +			PRINT_ER("Failed to allocate memory\n");

This message is redundant, the core already just told the user this, so
it's not needed to tell them this again.

And as an aside, the mess in WILC_MALLOC() needs to go as well, that's
horrid, and wrong :(

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] staging: wilc1000: fix memory allocation error check
  2015-07-14 21:16   ` Greg KH
@ 2015-07-14 23:14     ` Chaehyun Lim
  2015-07-14 23:43       ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-14 23:14 UTC (permalink / raw)
  To: Greg KH; +Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
	devel

On Wed, Jul 15, 2015 at 6:16 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, Jul 14, 2015 at 10:48:41AM +0900, Chaehyun Lim wrote:
>> Remove WILC_ERRORREPORT macro. If memory allocation is failed,
>> jump to a label to return this function with WILC_NO_MEM.
>>
>> Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
>> ---
>>  drivers/staging/wilc1000/host_interface.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
>> index ca97b70..f6ba7d1 100644
>> --- a/drivers/staging/wilc1000/host_interface.c
>> +++ b/drivers/staging/wilc1000/host_interface.c
>> @@ -7142,8 +7142,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
>>       /* Bug 4599 : if tail length = 0 skip allocating & copying */
>>       if (u32TailLen > 0) {
>>               pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
>> -             if (pstrSetBeaconParam->pu8Tail == NULL)
>> -                     WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
>> +             if (pstrSetBeaconParam->pu8Tail == NULL) {
>> +                     PRINT_ER("Failed to allocate memory\n");
>
> This message is redundant, the core already just told the user this, so
> it's not needed to tell them this again.
>
> And as an aside, the mess in WILC_MALLOC() needs to go as well, that's
> horrid, and wrong :(

Thank you for your comment. You think WILC_MALLOC() should be changed.
Could you give me a direction how this function should be changed?

thanks,
Chaehyun Lim
>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] staging: wilc1000: fix memory allocation error check
  2015-07-14 23:14     ` Chaehyun Lim
@ 2015-07-14 23:43       ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2015-07-14 23:43 UTC (permalink / raw)
  To: Chaehyun Lim
  Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
	devel

On Wed, Jul 15, 2015 at 08:14:08AM +0900, Chaehyun Lim wrote:
> On Wed, Jul 15, 2015 at 6:16 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Tue, Jul 14, 2015 at 10:48:41AM +0900, Chaehyun Lim wrote:
> >> Remove WILC_ERRORREPORT macro. If memory allocation is failed,
> >> jump to a label to return this function with WILC_NO_MEM.
> >>
> >> Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> >> ---
> >>  drivers/staging/wilc1000/host_interface.c | 7 +++++--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
> >> index ca97b70..f6ba7d1 100644
> >> --- a/drivers/staging/wilc1000/host_interface.c
> >> +++ b/drivers/staging/wilc1000/host_interface.c
> >> @@ -7142,8 +7142,11 @@ s32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
> >>       /* Bug 4599 : if tail length = 0 skip allocating & copying */
> >>       if (u32TailLen > 0) {
> >>               pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
> >> -             if (pstrSetBeaconParam->pu8Tail == NULL)
> >> -                     WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
> >> +             if (pstrSetBeaconParam->pu8Tail == NULL) {
> >> +                     PRINT_ER("Failed to allocate memory\n");
> >
> > This message is redundant, the core already just told the user this, so
> > it's not needed to tell them this again.
> >
> > And as an aside, the mess in WILC_MALLOC() needs to go as well, that's
> > horrid, and wrong :(
> 
> Thank you for your comment. You think WILC_MALLOC() should be changed.
> Could you give me a direction how this function should be changed?

Hm, let me turn the question around, why do you think it should be there
at all?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-14 23:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14  1:48 [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Chaehyun Lim
2015-07-14  1:48 ` [PATCH 2/2] staging: wilc1000: fix memory allocation error check Chaehyun Lim
2015-07-14 21:16   ` Greg KH
2015-07-14 23:14     ` Chaehyun Lim
2015-07-14 23:43       ` Greg KH
2015-07-14  2:32 ` [PATCH 1/2] staging: wilc1000: fix uninitialized variablie warning Julian Calaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).