lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed, 21 Nov 2007 21:26:57 +0300
From:	Dmitri Vorobiev <dmitri.vorobiev@...il.com>
To:	Rajesh Venkatasubramanian <vrajesh@...ch.edu>
CC:	Linux-kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH] loop cleanup in lib/prio_tree.c

Hi Rajesh,

It seems that using a goto-based construct in the prio_tree_next() is not justified, and using the while()-based loop is better from the coding style POV.

The patch below replaces the goto-based loop by a while-based one. However, if I overlooked something and using the goto operator in this routine is necessary, I would be grateful to you if you could explain why it is necessary.

Thanks.

Signed-off-by Dmitri Vorobiev <dmitri.vorobiev@...il.com>
---
diff --git a/lib/prio_tree.c b/lib/prio_tree.c
index ccfd850..d56880f 100644
--- a/lib/prio_tree.c
+++ b/lib/prio_tree.c
@@ -461,24 +461,23 @@ struct prio_tree_node *prio_tree_next(st
 	if (iter->cur == NULL)
 		return prio_tree_first(iter);
 
-repeat:
-	while (prio_tree_left(iter, &r_index, &h_index))
-		if (overlap(iter, r_index, h_index))
-			return iter->cur;
-
-	while (!prio_tree_right(iter, &r_index, &h_index)) {
-	    	while (!prio_tree_root(iter->cur) &&
-				iter->cur->parent->right == iter->cur)
-			prio_tree_parent(iter);
+	while (1) {
+		while (prio_tree_left(iter, &r_index, &h_index))
+			if (overlap(iter, r_index, h_index))
+				return iter->cur;
 
-		if (prio_tree_root(iter->cur))
-			return NULL;
+		while (!prio_tree_right(iter, &r_index, &h_index)) {
+			while (!prio_tree_root(iter->cur) &&
+					iter->cur->parent->right == iter->cur)
+				prio_tree_parent(iter);
 
-		prio_tree_parent(iter);
-	}
+			if (prio_tree_root(iter->cur))
+				return NULL;
 
-	if (overlap(iter, r_index, h_index))
-		return iter->cur;
+			prio_tree_parent(iter);
+		}
 
-	goto repeat;
+		if (overlap(iter, r_index, h_index))
+			return iter->cur;
+	}
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ