Skip to contentSkip to conversation

lib/kobject_uevent.c: Collapse unnecessary loop nesting (top_kobj)

PATCH New John Anthony Kazos Jr. 1 participant 1 message Apr 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/kobject_uevent.c: Collapse unnecessary loop nesting (top_kobj)

From: John Anthony Kazos Jr. <[email protected]>

Collapses a do..while() loop within an if() to a simple while() loop for simplicity and readability.

---

I'm sure GCC is able to handle this optimization decently, but there's no reason at all for the additional nesting level for the loop.

lib/kobject_uevent.c renamed from lib/kobject_uevent.c.orig +2 -4
@@ -95,10 +95,8 @@ int kobject_uevent_env(struct kobject *k
 
 	/* search the kset we belong to */
 	top_kobj = kobj;
-	if (!top_kobj->kset && top_kobj->parent) {
-		do {
-			top_kobj = top_kobj->parent;
-		} while (!top_kobj->kset && top_kobj->parent);
+	while (!top_kobj->kset && top_kobj->parent) {
+		top_kobj = top_kobj->parent;
 	}
 	if (!top_kobj->kset) {
 		pr_debug("kobject attempted to send uevent without kset!\n");