Skip to contentSkip to conversation

lib/kobject.c: Remove redundant check in populate_dir

PATCH In review yan 2 participants 2 messages Apr 21, 2012 – Apr 23, 2012

Subsystems (2)
lore
Share & tools
lore

yan

author
#0 lore raw

PATCH 1/1 lib/kobject.c: Remove redundant check in populate_dir

create_dir will call sysfs_create_dir and then populate_dir. If ktype of kobject is null, sysfs_craete_dir will lead to oops first. There is no need to check ktype in populate_dir.

---
 lib/kobject.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/kobject.c +1 -1
index bc05922..85d5e9b 100644
@@ -34,7 +34,7 @@ static int populate_dir(struct kobject *kobj)
 	int error = 0;
 	int i;
 
-	if (t && t->default_attrs) {
+	if (t->default_attrs) {
 		for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) {
 			error = sysfs_create_file(kobj, attr);
 			if (error)
Signature · 1 line
1.7.5.1
maintainer
#1 lore raw
Quoted 14 lines · yan

create_dir will call sysfs_create_dir and then populate_dir. If ktype of kobject is null, sysfs_craete_dir will lead to oops first. There is no need to check ktype in populate_dir.

---
 lib/kobject.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/kobject.c +0 -0
index bc05922..85d5e9b 100644

lib/kobject.c static int populate_dir(struct kobject *kobj) · line 37

Quoted 5 lines
lib/kobject.c +1 -1
@@ -34,7 +34,7 @@ static int populate_dir(struct kobject *kobj)
 	int error = 0;
 	int i;
 
-	if (t && t->default_attrs) {
+	if (t->default_attrs) {

I don't know, I think I'd like to keep this check for now, as it was put there for a reason. Yes, it's a reason lost to the sands of time, but is it costing us anything if it is still there?

greg k-h