diff mbox

[1/2] staging: wilc1000: fix uninitialized variablie warning

Message ID 1436838521-8200-1-git-send-email-chaehyun.lim@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show

Commit Message

Chaehyun Lim July 14, 2015, 1:48 a.m. UTC
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(-)

Comments

Julian Calaby July 14, 2015, 2:32 a.m. UTC | #1
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,
diff mbox

Patch

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;
 
 }