cpuset: fix return value of cpuset_populate()
PATCH 1/1 cpuset: fix return value of cpuset_populate()
- no need to check err == 0
- the last return value of cgroup_add_file() is ignored
--- kernel/cpuset.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/cpuset.c +2 -2
@@ -1482,10 +1482,10 @@ static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)if ((err =cgroup_add_file (cont, ss, &cft_spread_slab)) <0 )return err;/* memory_pressure_enabled is in root cpuset only */ -if (err ==0 && !cont->parent) +if (!cont->parent) err =cgroup_add_file (cont, ss, &cft_memory_pressure_enabled); -return 0 ; +return err; }/*
Signature · 1 line
1.5.4.rc3
[Resending a patch that Li Zefan just sent, adding the other Paul (Menage)
to the CC list. -pj]
- no need to check err == 0
- the last return value of cgroup_add_file() is ignored
--- kernel/cpuset.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/cpuset.c +2 -2
@@ -1482,10 +1482,10 @@ static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)if ((err =cgroup_add_file (cont, ss, &cft_spread_slab)) <0 )return err;/* memory_pressure_enabled is in root cpuset only */ -if (err ==0 && !cont->parent) +if (!cont->parent) err =cgroup_add_file (cont, ss, &cft_memory_pressure_enabled); -return 0 ; +return err; }/*
Signature · 7 lines
1.5.4.rc3
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.940.382.4214Quoted 3 lines · Paul Jackson
[Resending a patch that Li Zefan just sent, adding the other Paul (Menage)
to the CC list. -pj]
Thanks, I should have CCed Menage. :)
Quoted 25 lines
- no need to check err == 0
- the last return value ofcgroup_add_file()is ignoredSigned-off-by Li Zefan <[email protected]>--- kernel/cpuset.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)kernel/cpuset.c +2
-2@@ -1482,10 +1482,10 @@ static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)if ((err =cgroup_add_file (cont, ss, &cft_spread_slab)) <0 )return err;/* memory_pressure_enabled is in root cpuset only */ -if (err ==0 && !cont->parent) +if (!cont->parent) err =cgroup_add_file (cont, ss, &cft_memory_pressure_enabled); -return 0 ; +return err; }/*
Quoted 5 lines · Paul Jackson
- no need to check err == 0
- the last return value ofcgroup_add_file()is ignoredSigned-off-by Li Zefan <[email protected]>
Looks fine from a cleanliness PoV, although since we don't actually do anything with an error result from subsys->populate() (a behaviour that I sort of inherited from cpusets ...) it won't make a whole lot of difference to the code.
A better change would be to make cpuset_populate() use cgroup_add_files().
Paul
Quoted 30 lines
---
kernel/cpuset.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)diff --git
a/kernel/cpuset.cb/kernel/cpuset.c
index 3e296ed..1c5b2d2 100644
---a/kernel/cpuset.c
+++b/kernel/cpuset.c
@@ -1482,10 +1482,10 @@ static intcpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont)if ((err = cgroup_add_file(cont, ss, &cft_spread_slab)) < 0) return err; /* memory_pressure_enabled is in root cpuset only */- if (err == 0 && !cont->parent)
+ if (!cont->parent)
err = cgroup_add_file(cont, ss,
&cft_memory_pressure_enabled);
- return 0;
+ return err;
}/*
--
1.5.4.rc3--
I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.940.382.4214
Quoted 4 lines · Paul Menage
Quoted 3 lines · Paul Jackson
- no need to check err == 0
- the last return value ofcgroup_add_file()is ignored
Quoted 9 lines
Quoted 1 line
Signed-off-by Li Zefan <[email protected]>Looks fine from a cleanliness PoV, although since we don't actually do anything with an error result from
subsys->populate()(a behaviour that I sort of inherited from cpusets ...) it won't make a whole lot of difference to the code.A better change would be to make
cpuset_populate()usecgroup_add_files().
Yes, I'm considering this, and I will verify if this will save some bytes in the object file.