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

From: John Anthony Kazos Jr.
Date: Wed Apr 04 2007 - 07:40:00 EST


From: John Anthony Kazos Jr. <jakj@xxxxxxxxxxx>

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

Signed-off-by: John Anthony Kazos Jr. <jakj@xxxxxxxxxxx>

---

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.

--- linux-2.6.20.4/lib/kobject_uevent.c.orig 2007-04-04 07:25:08.000000000 -0400
+++ linux-2.6.20.4/lib/kobject_uevent.c 2007-04-04 07:27:28.000000000 -0400
@@ -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");
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/