public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/kobject.c : Remove redundant check in create_dir
@ 2012-04-20 13:25 yan
  0 siblings, 0 replies; only message in thread
From: yan @ 2012-04-20 13:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, message.get

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.

Signed-off-by: Yan Hong <clouds.yan@gmail.com>
---
 lib/kobject.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index aeefa8b..38fcc60 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -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;
 }
-- 
1.7.5.1




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-20 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-20 13:25 [PATCH] lib/kobject.c : Remove redundant check in create_dir yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox