All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
@ 2013-05-06  7:21 ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-05-06  7:21 UTC (permalink / raw)
  To: J. Bruce Fields, Trond Myklebust
  Cc: linux-nfs, netdev, linux-kernel, Geert Uytterhoeven

net/sunrpc/auth_gss/gss_rpc_xdr.c: In function ‘gssx_dec_option_array’:
net/sunrpc/auth_gss/gss_rpc_xdr.c:258: warning: ‘creds’ may be used uninitialized in this function

Return early if count is zero, to make it clearer to the compiler (and the
casual reviewer) that no more processing is done.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 net/sunrpc/auth_gss/gss_rpc_xdr.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
index 5c4c61d..a1e1b1a 100644
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
@@ -264,25 +264,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
 	if (unlikely(p == NULL))
 		return -ENOSPC;
 	count = be32_to_cpup(p++);
-	if (count != 0) {
-		/* we recognize only 1 currently: CREDS_VALUE */
-		oa->count = 1;
+	if (!count)
+		return 0;
 
-		oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
-		if (!oa->data)
-			return -ENOMEM;
+	/* we recognize only 1 currently: CREDS_VALUE */
+	oa->count = 1;
 
-		creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
-		if (!creds) {
-			kfree(oa->data);
-			return -ENOMEM;
-		}
+	oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
+	if (!oa->data)
+		return -ENOMEM;
 
-		oa->data[0].option.data = CREDS_VALUE;
-		oa->data[0].option.len = sizeof(CREDS_VALUE);
-		oa->data[0].value.data = (void *)creds;
-		oa->data[0].value.len = 0;
+	creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
+	if (!creds) {
+		kfree(oa->data);
+		return -ENOMEM;
 	}
+
+	oa->data[0].option.data = CREDS_VALUE;
+	oa->data[0].option.len = sizeof(CREDS_VALUE);
+	oa->data[0].value.data = (void *)creds;
+	oa->data[0].value.len = 0;
+
 	for (i = 0; i < count; i++) {
 		gssx_buffer dummy = { 0, NULL };
 		u32 length;
-- 
1.7.0.4


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

* [PATCH] SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
@ 2013-05-06  7:21 ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-05-06  7:21 UTC (permalink / raw)
  To: J. Bruce Fields, Trond Myklebust
  Cc: linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

net/sunrpc/auth_gss/gss_rpc_xdr.c: In function ‘gssx_dec_option_array’:
net/sunrpc/auth_gss/gss_rpc_xdr.c:258: warning: ‘creds’ may be used uninitialized in this function

Return early if count is zero, to make it clearer to the compiler (and the
casual reviewer) that no more processing is done.

Signed-off-by: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
 net/sunrpc/auth_gss/gss_rpc_xdr.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
index 5c4c61d..a1e1b1a 100644
--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
+++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
@@ -264,25 +264,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
 	if (unlikely(p == NULL))
 		return -ENOSPC;
 	count = be32_to_cpup(p++);
-	if (count != 0) {
-		/* we recognize only 1 currently: CREDS_VALUE */
-		oa->count = 1;
+	if (!count)
+		return 0;
 
-		oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
-		if (!oa->data)
-			return -ENOMEM;
+	/* we recognize only 1 currently: CREDS_VALUE */
+	oa->count = 1;
 
-		creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
-		if (!creds) {
-			kfree(oa->data);
-			return -ENOMEM;
-		}
+	oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
+	if (!oa->data)
+		return -ENOMEM;
 
-		oa->data[0].option.data = CREDS_VALUE;
-		oa->data[0].option.len = sizeof(CREDS_VALUE);
-		oa->data[0].value.data = (void *)creds;
-		oa->data[0].value.len = 0;
+	creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
+	if (!creds) {
+		kfree(oa->data);
+		return -ENOMEM;
 	}
+
+	oa->data[0].option.data = CREDS_VALUE;
+	oa->data[0].option.len = sizeof(CREDS_VALUE);
+	oa->data[0].value.data = (void *)creds;
+	oa->data[0].value.len = 0;
+
 	for (i = 0; i < count; i++) {
 		gssx_buffer dummy = { 0, NULL };
 		u32 length;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
@ 2013-05-06 12:55   ` J. Bruce Fields
  0 siblings, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2013-05-06 12:55 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Trond Myklebust, linux-nfs, netdev, linux-kernel

On Mon, May 06, 2013 at 09:21:03AM +0200, Geert Uytterhoeven wrote:
> net/sunrpc/auth_gss/gss_rpc_xdr.c: In function ‘gssx_dec_option_array’:
> net/sunrpc/auth_gss/gss_rpc_xdr.c:258: warning: ‘creds’ may be used uninitialized in this function
> 
> Return early if count is zero, to make it clearer to the compiler (and the
> casual reviewer) that no more processing is done.

Looks reasonable; applying for 3.10.--b.

> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  net/sunrpc/auth_gss/gss_rpc_xdr.c |   32 +++++++++++++++++---------------
>  1 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
> index 5c4c61d..a1e1b1a 100644
> --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
> +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
> @@ -264,25 +264,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
>  	if (unlikely(p == NULL))
>  		return -ENOSPC;
>  	count = be32_to_cpup(p++);
> -	if (count != 0) {
> -		/* we recognize only 1 currently: CREDS_VALUE */
> -		oa->count = 1;
> +	if (!count)
> +		return 0;
>  
> -		oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
> -		if (!oa->data)
> -			return -ENOMEM;
> +	/* we recognize only 1 currently: CREDS_VALUE */
> +	oa->count = 1;
>  
> -		creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
> -		if (!creds) {
> -			kfree(oa->data);
> -			return -ENOMEM;
> -		}
> +	oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
> +	if (!oa->data)
> +		return -ENOMEM;
>  
> -		oa->data[0].option.data = CREDS_VALUE;
> -		oa->data[0].option.len = sizeof(CREDS_VALUE);
> -		oa->data[0].value.data = (void *)creds;
> -		oa->data[0].value.len = 0;
> +	creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
> +	if (!creds) {
> +		kfree(oa->data);
> +		return -ENOMEM;
>  	}
> +
> +	oa->data[0].option.data = CREDS_VALUE;
> +	oa->data[0].option.len = sizeof(CREDS_VALUE);
> +	oa->data[0].value.data = (void *)creds;
> +	oa->data[0].value.len = 0;
> +
>  	for (i = 0; i < count; i++) {
>  		gssx_buffer dummy = { 0, NULL };
>  		u32 length;
> -- 
> 1.7.0.4
> 

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

* Re: [PATCH] SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
@ 2013-05-06 12:55   ` J. Bruce Fields
  0 siblings, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2013-05-06 12:55 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Trond Myklebust, linux-nfs-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Mon, May 06, 2013 at 09:21:03AM +0200, Geert Uytterhoeven wrote:
> net/sunrpc/auth_gss/gss_rpc_xdr.c: In function ‘gssx_dec_option_array’:
> net/sunrpc/auth_gss/gss_rpc_xdr.c:258: warning: ‘creds’ may be used uninitialized in this function
> 
> Return early if count is zero, to make it clearer to the compiler (and the
> casual reviewer) that no more processing is done.

Looks reasonable; applying for 3.10.--b.

> 
> Signed-off-by: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
> ---
>  net/sunrpc/auth_gss/gss_rpc_xdr.c |   32 +++++++++++++++++---------------
>  1 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c
> index 5c4c61d..a1e1b1a 100644
> --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c
> +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c
> @@ -264,25 +264,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
>  	if (unlikely(p == NULL))
>  		return -ENOSPC;
>  	count = be32_to_cpup(p++);
> -	if (count != 0) {
> -		/* we recognize only 1 currently: CREDS_VALUE */
> -		oa->count = 1;
> +	if (!count)
> +		return 0;
>  
> -		oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
> -		if (!oa->data)
> -			return -ENOMEM;
> +	/* we recognize only 1 currently: CREDS_VALUE */
> +	oa->count = 1;
>  
> -		creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
> -		if (!creds) {
> -			kfree(oa->data);
> -			return -ENOMEM;
> -		}
> +	oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
> +	if (!oa->data)
> +		return -ENOMEM;
>  
> -		oa->data[0].option.data = CREDS_VALUE;
> -		oa->data[0].option.len = sizeof(CREDS_VALUE);
> -		oa->data[0].value.data = (void *)creds;
> -		oa->data[0].value.len = 0;
> +	creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
> +	if (!creds) {
> +		kfree(oa->data);
> +		return -ENOMEM;
>  	}
> +
> +	oa->data[0].option.data = CREDS_VALUE;
> +	oa->data[0].option.len = sizeof(CREDS_VALUE);
> +	oa->data[0].value.data = (void *)creds;
> +	oa->data[0].value.len = 0;
> +
>  	for (i = 0; i < count; i++) {
>  		gssx_buffer dummy = { 0, NULL };
>  		u32 length;
> -- 
> 1.7.0.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2013-05-06 12:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06  7:21 [PATCH] SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning Geert Uytterhoeven
2013-05-06  7:21 ` Geert Uytterhoeven
2013-05-06 12:55 ` J. Bruce Fields
2013-05-06 12:55   ` J. Bruce Fields

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.