public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uml/net_kern: Eliminate NULL test after alloc_bootmem
@ 2014-07-19 11:34 Himangi Saraogi
  2014-07-23 22:24 ` Richard Weinberger
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-07-19 11:34 UTC (permalink / raw)
  To: Jeff Dike, Richard Weinberger, user-mode-linux-devel,
	user-mode-linux-user, linux-kernel
  Cc: Julia Lawall

alloc_bootmem and related functions never return NULL. Thus a NULL
test or memset after calls to these functions is unnecessary.

The following Coccinelle semantic patch was used for making the change:

@@
expression E;
statement S;
@@

E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- if (E == NULL) S

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 arch/um/drivers/net_kern.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 7d26d9c..f70dd54 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -659,10 +659,6 @@ static int __init eth_setup(char *str)
 	}
 
 	new = alloc_bootmem(sizeof(*new));
-	if (new == NULL) {
-		printk(KERN_ERR "eth_init : alloc_bootmem failed\n");
-		return 1;
-	}
 
 	INIT_LIST_HEAD(&new->list);
 	new->index = n;
-- 
1.9.1


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

* Re: [PATCH] uml/net_kern: Eliminate NULL test after alloc_bootmem
  2014-07-19 11:34 [PATCH] uml/net_kern: Eliminate NULL test after alloc_bootmem Himangi Saraogi
@ 2014-07-23 22:24 ` Richard Weinberger
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2014-07-23 22:24 UTC (permalink / raw)
  To: Himangi Saraogi, Jeff Dike, user-mode-linux-devel,
	user-mode-linux-user, linux-kernel
  Cc: Julia Lawall

Himangi,

Am 19.07.2014 13:34, schrieb Himangi Saraogi:
> alloc_bootmem and related functions never return NULL. Thus a NULL
> test or memset after calls to these functions is unnecessary.
> 
> The following Coccinelle semantic patch was used for making the change:
> 
> @@
> expression E;
> statement S;
> @@
> 
> E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
> ... when != E
> - if (E == NULL) S
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Thank you! All three patches are now queued for 3.17.

Thanks,
//richard

> ---
>  arch/um/drivers/net_kern.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
> index 7d26d9c..f70dd54 100644
> --- a/arch/um/drivers/net_kern.c
> +++ b/arch/um/drivers/net_kern.c
> @@ -659,10 +659,6 @@ static int __init eth_setup(char *str)
>  	}
>  
>  	new = alloc_bootmem(sizeof(*new));
> -	if (new == NULL) {
> -		printk(KERN_ERR "eth_init : alloc_bootmem failed\n");
> -		return 1;
> -	}
>  
>  	INIT_LIST_HEAD(&new->list);
>  	new->index = n;
> 

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

end of thread, other threads:[~2014-07-23 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-19 11:34 [PATCH] uml/net_kern: Eliminate NULL test after alloc_bootmem Himangi Saraogi
2014-07-23 22:24 ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox