linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mm: initialize kmem_cache pointer to NULL
  2015-10-20 22:04 [PATCH] mm: initialize kmem_cache pointer to NULL Alexandru Moise
@ 2015-10-20 20:06 ` Christoph Lameter
  2015-10-21 20:32 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Lameter @ 2015-10-20 20:06 UTC (permalink / raw)
  To: Alexandru Moise
  Cc: penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm, linux-kernel

On Tue, 20 Oct 2015, Alexandru Moise wrote:

> The assignment to NULL within the error condition was written
> in a 2014 patch to suppress a compiler warning.
> However it would be cleaner to just initialize the kmem_cache
> to NULL and just return it in case of an error condition.

Acked-by: Christoph Lameter <cl@linux.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH] mm: initialize kmem_cache pointer to NULL
@ 2015-10-20 22:04 Alexandru Moise
  2015-10-20 20:06 ` Christoph Lameter
  2015-10-21 20:32 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Alexandru Moise @ 2015-10-20 22:04 UTC (permalink / raw)
  To: cl; +Cc: penberg, rientjes, iamjoonsoo.kim, akpm, linux-mm, linux-kernel

The assignment to NULL within the error condition was written
in a 2014 patch to suppress a compiler warning.
However it would be cleaner to just initialize the kmem_cache
to NULL and just return it in case of an error condition.

Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>
---
 mm/slab_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 5ce4fae..cf0b7bb 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -384,7 +384,7 @@ struct kmem_cache *
 kmem_cache_create(const char *name, size_t size, size_t align,
 		  unsigned long flags, void (*ctor)(void *))
 {
-	struct kmem_cache *s;
+	struct kmem_cache *s = NULL;
 	const char *cache_name;
 	int err;
 
@@ -396,7 +396,6 @@ kmem_cache_create(const char *name, size_t size, size_t align,
 
 	err = kmem_cache_sanity_check(name, size);
 	if (err) {
-		s = NULL;	/* suppress uninit var warning */
 		goto out_unlock;
 	}
 
-- 
2.6.1

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

* Re: [PATCH] mm: initialize kmem_cache pointer to NULL
  2015-10-20 22:04 [PATCH] mm: initialize kmem_cache pointer to NULL Alexandru Moise
  2015-10-20 20:06 ` Christoph Lameter
@ 2015-10-21 20:32 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2015-10-21 20:32 UTC (permalink / raw)
  To: Alexandru Moise; +Cc: cl, penberg, iamjoonsoo.kim, akpm, linux-mm, linux-kernel

On Tue, 20 Oct 2015, Alexandru Moise wrote:

> The assignment to NULL within the error condition was written
> in a 2014 patch to suppress a compiler warning.
> However it would be cleaner to just initialize the kmem_cache
> to NULL and just return it in case of an error condition.
> 
> Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-10-21 20:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 22:04 [PATCH] mm: initialize kmem_cache pointer to NULL Alexandru Moise
2015-10-20 20:06 ` Christoph Lameter
2015-10-21 20:32 ` David Rientjes

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