2020-06-14 02:31:07

by zzuedu2000

[permalink] [raw]
Subject: [PATCH] cgroup: Refactor two assignments in css_task_iter_next_css_set()

From: Wei Fenghai <[email protected]>

Combine two assignments for the variable ā€˜lā€™ into one statement.

Signed-off-by: Wei Fenghai <[email protected]>
---
kernel/cgroup/cgroup.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1ea181a58465..c3e6db6e44d8 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4352,8 +4352,7 @@ static struct css_set *css_task_iter_next_css_set(struct css_task_iter *it)
}

/* find the next cset */
- l = it->cset_pos;
- l = l->next;
+ l = it->cset_pos->next;
if (l == it->cset_head) {
it->cset_pos = NULL;
return NULL;
--
2.17.1



2020-06-14 18:12:27

by James Bottomley

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Refactor two assignments in css_task_iter_next_css_set()

On Sun, 2020-06-14 at 10:28 +0800, [email protected] wrote:
> From: Wei Fenghai <[email protected]>
>
> Combine two assignments for the variable ā€˜lā€™ into one statement.

The problem with this commit message isn't the description, we can all
see what the change does, it's the justification. Why is there any
reason to do this? My version of gcc does this as an optimization
anyway, so the patch doesn't change to the binary output and it's
arguable that having two statements instead of one makes the code
marginally more readable.

Regards,

James

2020-06-14 23:26:40

by zzuedu2000

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Refactor two assignments in css_task_iter_next_css_set()

On Sun, 2020-06-14 at 18:10 +0800, James.Bottomley@xxxxxxx wrote:

> it's arguable that having two statements instead of one makes the code
> marginally more readable.

Above the function there is a similar line of code:
l = it->tcset_pos->next;
One line of code makes the code style consistent and more readable


Regards,

Wei Fenghai

2020-06-15 01:13:59

by Zefan Li

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Refactor two assignments in css_task_iter_next_css_set()

On 2020/6/15 7:22, [email protected] wrote:
> On Sun, 2020-06-14 at 18:10 +0800, James.Bottomley@xxxxxxx wrote:
>
>> it's arguable that having two statements instead of one makes the code
>> marginally more readable.
>
> Above the function there is a similar line of code:
> l = it->tcset_pos->next;
> One line of code makes the code style consistent and more readable
>

It would be much better if you are fixing a bug or developing a new feature
and while at it you do this cleanup conveniently, but this patch alone has
little value.