mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/kobject_uevent.c: Collapse unnecessary loop nesting (top_kobj)
@ 2007-04-04 11:39 John Anthony Kazos Jr.
  0 siblings, 0 replies; only message in thread
From: John Anthony Kazos Jr. @ 2007-04-04 11:39 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel

From: John Anthony Kazos Jr. <jakj@j-a-k-j.com>

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@j-a-k-j.com>

---

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");

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

only message in thread, other threads:[~2007-04-04 11:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-04 11:39 [PATCH] lib/kobject_uevent.c: Collapse unnecessary loop nesting (top_kobj) John Anthony Kazos Jr.

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

all inboxes | Powered by JetHome®