Skip to contentSkip to conversation

lib/kobject.c : Remove redundant check in create_dir

PATCH New yan 1 participant 1 message Apr 20, 2012

Subsystems (2)
lore
Share & tools
lore

yan

author
#0 lore raw

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

create_dir is a static function used only in kobject_add_internal. There's no need to do check here, for kobject_add_internal will reject kobject with invalid name.

---
 lib/kobject.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
lib/kobject.c +5 -7
index aeefa8b..38fcc60 100644
@@ -47,13 +47,11 @@ static int populate_dir(struct kobject *kobj)
 static int create_dir(struct kobject *kobj)
 {
 	int error = 0;
-	if (kobject_name(kobj)) {
-		error = sysfs_create_dir(kobj);
-		if (!error) {
-			error = populate_dir(kobj);
-			if (error)
-				sysfs_remove_dir(kobj);
-		}
+	error = sysfs_create_dir(kobj);
+	if (!error) {
+		error = populate_dir(kobj);
+		if (error)
+			sysfs_remove_dir(kobj);
 	}
 	return error;
 }
Signature · 1 line
1.7.5.1