summaryrefslogtreecommitdiff
path: root/extra/cvsps/use-offsetof-macro.patch
blob: ff2961f07a2a75ad93477bcebe61086fa48e679a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From 4fad63b82746ea571edc2ec1100ad3208cf5af08 Mon Sep 17 00:00:00 2001
From: Eric Hopper <hopper@omnifarious.org>
Date: Fri, 29 Jun 2007 01:30:09 -0700
Subject: [PATCH] Use offsetof macro instead of unportable pointer arithmetic.

---
 cbtcommon/list.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/cbtcommon/list.h b/cbtcommon/list.h
index 4ee245d..cf4b3ed 100644
--- a/cbtcommon/list.h
+++ b/cbtcommon/list.h
@@ -23,6 +23,7 @@
  */
 
 #include "inline.h"
+#include <stddef.h>
 
 struct list_head {
         struct list_head *next, *prev;
@@ -107,6 +108,6 @@ static INLINE void list_splice(struct list_head *list, struct list_head *head)
 }
 
 #define list_entry(ptr, type, member) \
-        ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+   ((type *)((char *)(ptr)-offsetof(type, member)))
 
 #endif /* _COMMON_LIST_H */
-- 
1.6.5.GIT