summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorKarel Zak2018-07-20 15:22:35 +0200
committerKarel Zak2018-07-20 15:22:35 +0200
commiteb06d5d4b2f54a98b5779c11c3813832d6f98db2 (patch)
tree460547b3384014d6e4e18fc30291382b35e5bc31 /include/c.h
parentlibblkid: const qualifier cleanup (diff)
downloadkernel-qcow2-util-linux-eb06d5d4b2f54a98b5779c11c3813832d6f98db2.tar.gz
kernel-qcow2-util-linux-eb06d5d4b2f54a98b5779c11c3813832d6f98db2.tar.xz
kernel-qcow2-util-linux-eb06d5d4b2f54a98b5779c11c3813832d6f98db2.zip
include/list, include/c: update and container_of()
* update container_of() to version without "const" qualifier * use container_of() in list_entry() Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/c.h b/include/c.h
index c8bcb375b..a240f4f6c 100644
--- a/include/c.h
+++ b/include/c.h
@@ -129,10 +129,16 @@
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ */
#ifndef container_of
-#define container_of(ptr, type, member) __extension__ ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+#define container_of(ptr, type, member) __extension__ ({ \
+ void *__mptr = (void *)(ptr); \
+ ((type *)(__mptr - offsetof(type, member))); })
#endif
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME