* [PATCH] mm/slab_common: reduce an if statement in create_cache()
@ 2023-06-06 6:55 Zhen Lei
2023-06-06 7:48 ` Hyeonggon Yoo
0 siblings, 1 reply; 3+ messages in thread
From: Zhen Lei @ 2023-06-06 6:55 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
Cc: 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 <thunder.leizhen@huawei.com>
---
mm/slab_common.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 607249785c077e9..f6fe35105774944 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -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);
}
/**
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/slab_common: reduce an if statement in create_cache()
2023-06-06 6:55 [PATCH] mm/slab_common: reduce an if statement in create_cache() Zhen Lei
@ 2023-06-06 7:48 ` Hyeonggon Yoo
2023-06-06 8:48 ` Vlastimil Babka
0 siblings, 1 reply; 3+ messages in thread
From: Hyeonggon Yoo @ 2023-06-06 7:48 UTC (permalink / raw)
To: Zhen Lei
Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton, Vlastimil Babka, Roman Gushchin, linux-mm,
linux-kernel
On Tue, Jun 06, 2023 at 02:55:43PM +0800, Zhen Lei wrote:
> 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 <thunder.leizhen@huawei.com>
> ---
> mm/slab_common.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 607249785c077e9..f6fe35105774944 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -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);
> }
>
> /**
Hi Zhen,
nice cleanup!
Looks correct to me,
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> --
> 2.25.1
>
--
Hyeonggon Yoo
Doing kernel stuff as a hobby
Undergraduate | Chungnam National University
Dept. Computer Science & Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/slab_common: reduce an if statement in create_cache()
2023-06-06 7:48 ` Hyeonggon Yoo
@ 2023-06-06 8:48 ` Vlastimil Babka
0 siblings, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2023-06-06 8:48 UTC (permalink / raw)
To: Hyeonggon Yoo, Zhen Lei
Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton, Roman Gushchin, linux-mm, linux-kernel
On 6/6/23 09:48, Hyeonggon Yoo wrote:
> On Tue, Jun 06, 2023 at 02:55:43PM +0800, Zhen Lei wrote:
>> 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 <thunder.leizhen@huawei.com>
>> ---
>> mm/slab_common.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 607249785c077e9..f6fe35105774944 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -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);
>> }
>>
>> /**
>
> Hi Zhen,
> nice cleanup!
>
> Looks correct to me,
> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Thanks, added to slab/for-6.5/cleanup
>> --
>> 2.25.1
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-06 8:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 6:55 [PATCH] mm/slab_common: reduce an if statement in create_cache() Zhen Lei
2023-06-06 7:48 ` Hyeonggon Yoo
2023-06-06 8:48 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®