Skip to contentSkip to conversation

hlist_add_after broken?

PATCH Pedro Emanuel M. D. Pinto 1 participant 1 message Apr 17, 2004

lore
Share & tools
lore
#0 lore raw

There is an inline function (hlist_add_after) in include/linux/list.h which I believe is broken. The algorithm used doesn't make sence to me so if it actually ok I would appreciate if someone could explain it to me. Below is a patch I made against version 2.6.1 of what I believe is a working function.

regards,

Pedro Pinto

linux/list.h renamed from linux/list.h.orig +6 -3
@@ -525,9 +525,12 @@
 static __inline__ void hlist_add_after(struct hlist_node *n,
 				       struct hlist_node *next)
 {
-	next->next	= n->next;
-	*(next->pprev)	= n;
-	n->next		= next;
+	next->next = n->next;
+	n->next = next;
+	next->pprev = &n->next;
+
+	if(next->next)
+		next->next->pprev  = &next->next;
 }
 
 #define hlist_entry(ptr, type, member) container_of(ptr,type,member)