All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [PATCH] minor cleanup of type-checking for ptrlist.h
@ 2005-12-31  7:20 Alecs King
  0 siblings, 0 replies; only message in thread
From: Alecs King @ 2005-12-31  7:20 UTC (permalink / raw)
  To: linux-sparse

DECLARE_PTR_LIST and friends are for 'Silly type-safety check'.  The
member (type *list[1]) of strust listname is never directly
dereferenced or used except for CHECK_TYPE things.  So why was it made
an array of pointer instead of simply a pointer?  IMHO, it gives no
benefits but complicates things a bit.  Or am i missing something?

This patch just change the array of pointer to a pointer.

Signed-off-by: Alecs King <alecsk@gmail.com>


diff --git a/dissect.c b/dissect.c
index 7a13ffa..be809f1 100644
--- a/dissect.c
+++ b/dissect.c
@@ -14,7 +14,7 @@
 
 #define	DO_LIST(l__, p__, expr__)		\
 	do {					\
-		typeof(l__->list[0]) p__;	\
+		typeof(l__->list) p__;	\
 		FOR_EACH_PTR(l__, p__)		\
 			expr__;			\
 		END_FOR_EACH_PTR(p__);		\
@@ -22,8 +22,8 @@
 
 #define	DO_2_LIST(l1__,l2__, p1__,p2__, expr__)	\
 	do {					\
-		typeof(l1__->list[0]) p1__;	\
-		typeof(l2__->list[0]) p2__;	\
+		typeof(l1__->list) p1__;	\
+		typeof(l2__->list) p2__;	\
 		PREPARE_PTR_LIST(l1__, p1__);	\
 		FOR_EACH_PTR(l2__, p2__)	\
 			expr__;			\
diff --git a/ptrlist.h b/ptrlist.h
index b42a0ca..6f1a289 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -11,10 +11,10 @@
 	(type *)((void *)(ptr) - offsetof(type, member))
 
 /* Silly type-safety check ;) */
-#define DECLARE_PTR_LIST(listname,type)	struct listname { type *list[1]; }
-#define CHECK_TYPE(head,ptr)		(void)(&(ptr) == &(head)->list[0])
-#define TYPEOF(head)			__typeof__(&(head)->list[0])
-#define VRFY_PTR_LIST(head)		(void)(sizeof((head)->list[0]))
+#define DECLARE_PTR_LIST(listname,type)	struct listname { type *list; }
+#define CHECK_TYPE(head,ptr)		(void)(&(ptr) == &(head)->list)
+#define TYPEOF(head)			__typeof__(&(head)->list)
+#define VRFY_PTR_LIST(head)		(void)(sizeof((head)->list))
 
 #define LIST_NODE_NR (29)
 

-- 
Alecs King

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

only message in thread, other threads:[~2005-12-31  7:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-31  7:20 [RFC] [PATCH] minor cleanup of type-checking for ptrlist.h Alecs King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.