mm/slab_common: reduce an if statement in create_cache()
Subsystems (2)
PATCH 1/1 mm/slab_common: reduce an if statement in create_cache()
Move the 'out:' statement block out of the successful path to avoid redundant check on 'err'. The value of 'err' is always zero on success and negative on failure.
No functional changes, no performance improvements, just a little more readability.
--- mm/slab_common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/slab_common.c +2 -4
@@ -236,14 +236,12 @@ static struct kmem_cache *create_cache(const char *name, s->refcount =1 ;list_add (&s->list, &slab_caches); -out: -if (err) -return ERR_PTR (err);return s; out_free_cache:kmem_cache_free (kmem_cache, s); - goto out; +out: +return ERR_PTR (err); }/**
Signature · 1 line
2.25.1
Quoted 23 lines · Zhen Lei
Move the 'out:' statement block out of the successful path to avoid redundant check on 'err'. The value of 'err' is always zero on success and negative on failure.
No functional changes, no performance improvements, just a little more readability.
Signed-off-by Zhen Lei <[email protected]>--- mm/slab_common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)mm/slab_common.c +0
-3@@ -236,14 +236,12 @@ static struct kmem_cache *create_cache(const char *name, s->refcount =1 ;list_add (&s->list, &slab_caches); -out: -if (err) -return ERR_PTR (err);
mm/slab_common.c static struct kmem_cache *create_cache(const char *name, · line 247
Quoted 10 lines
mm/slab_common.c +2
-1return s; out_free_cache:kmem_cache_free (kmem_cache, s); - goto out; +out: +return ERR_PTR (err); }/**
Hi Zhen,
nice cleanup!
Looks correct to me,
Quoted 3 lines
Signature · 1 line
2.25.1
Signature · 5 lines
Hyeonggon Yoo Doing kernel stuff as a hobby Undergraduate | Chungnam National University Dept. Computer Science & Engineering
Quoted 33 lines · Hyeonggon Yoo
Quoted 32 lines · Zhen Lei
Move the 'out:' statement block out of the successful path to avoid redundant check on 'err'. The value of 'err' is always zero on success and negative on failure.
No functional changes, no performance improvements, just a little more readability.
Signed-off-by Zhen Lei <[email protected]>--- mm/slab_common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)mm/slab_common.c +2
-4@@ -236,14 +236,12 @@ static struct kmem_cache *create_cache(const char *name, s->refcount =1 ;list_add (&s->list, &slab_caches); -out: -if (err) -return ERR_PTR (err);return s; out_free_cache:kmem_cache_free (kmem_cache, s); - goto out; +out: +return ERR_PTR (err); }
Quoted 7 lines
mm/slab_common.c static struct kmem_cache *create_cache(const char *name, · line 247
Quoted 1 line
mm/slab_common.c +0
-0/** Hi Zhen,
nice cleanup!Looks correct to me,
Reviewed-by Hyeonggon Yoo <[email protected]>
Thanks, added to slab/for-6.5/cleanup
Quoted 4 lines
Quoted 3 lines
Signature · 1 line
2.25.1