Skip to contentSkip to conversation

cpuset: fix return value of cpuset_populate()

PATCH In review Li Zefan 3 participants 5 messages Feb 27, 2008 – Feb 28, 2008

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

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
index 3e296ed..1c5b2d2 100644
@@ -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
#1 lore raw

[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
index 3e296ed..1c5b2d2 100644
@@ -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.4214
author
#2 lore raw
Quoted 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 of cgroup_add_file() is ignored

---
 kernel/cpuset.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
kernel/cpuset.c +2 -2
index 3e296ed..1c5b2d2 100644
@@ -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;
 }
 
 /*
#3 lore raw
In reply to Paul Jackson
Quoted 5 lines · Paul Jackson

- no need to check err == 0
- the last return value of cgroup_add_file() is ignored

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.c b/kernel/cpuset.c
index 3e296ed..1c5b2d2 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -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;
}

/*
--
1.5.4.rc3

--
I won't rest till it's the best ... Programmer, Linux Scalability Paul Jackson <[email protected]> 1.940.382.4214

author
#4 lore raw
Quoted 4 lines · Paul Menage
Quoted 3 lines · Paul Jackson

- no need to check err == 0
- the last return value of cgroup_add_file() is ignored

Quoted 9 lines
Quoted 1 line

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().

Yes, I'm considering this, and I will verify if this will save some bytes in the object file.