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>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 16 Mar 2009 00:23:37 +0900
From:	Akinobu Mita <akinobu.mita@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	akpm@...ux-foundation.org
Subject: [PATCH 1/2] list: unify hlist_add functions

Unify hlist_add_head(), hlist_add_before(), and hlist_add_after().

Signed-off-by: Akinobu Mita <akinobu.mita@...il.com>
---
 include/linux/list.h |   33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

Index: 2.6/include/linux/list.h
===================================================================
--- 2.6.orig/include/linux/list.h
+++ 2.6/include/linux/list.h
@@ -588,35 +588,36 @@ static inline void hlist_del_init(struct
 	}
 }
 
+/*
+ * This is only for internal hlist manipulation where we know
+ * the pprev/next entries already!
+ */
+static inline void __hlist_add(struct hlist_node *new,
+			struct hlist_node **pprev, struct hlist_node *next)
+{
+	new->next = next;
+	if (next)
+		next->pprev = &new->next;
+	*pprev = new;
+	new->pprev = pprev;
+}
+
 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
 {
-	struct hlist_node *first = h->first;
-	n->next = first;
-	if (first)
-		first->pprev = &n->next;
-	h->first = n;
-	n->pprev = &h->first;
+	__hlist_add(n, &h->first, h->first);
 }
 
 /* next must be != NULL */
 static inline void hlist_add_before(struct hlist_node *n,
 					struct hlist_node *next)
 {
-	n->pprev = next->pprev;
-	n->next = next;
-	next->pprev = &n->next;
-	*(n->pprev) = n;
+	__hlist_add(n, next->pprev, next);
 }
 
 static inline void hlist_add_after(struct hlist_node *n,
 					struct hlist_node *next)
 {
-	next->next = n->next;
-	n->next = next;
-	next->pprev = &n->next;
-
-	if(next->next)
-		next->next->pprev  = &next->next;
+	__hlist_add(next, &n->next, n->next);
 }
 
 /*
--
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