summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2020-05-15 14:41:23 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2020-05-20 16:01:20 +0200
commitdeb51601818ec9d2f9a29205896125c82cf6ce00 (patch)
treee307912684f50ce5d434651bd4f03669790c14e8
parent16da6651a1eebd776aa461db76cecaf3997cbf50 (diff)
downloadlvm2-deb51601818ec9d2f9a29205896125c82cf6ce00.tar.gz
list: use container_of
Reuse macro
-rw-r--r--base/data-struct/list.h4
-rw-r--r--daemons/lvmlockd/lvmlockd-internal.h6
2 files changed, 4 insertions, 6 deletions
diff --git a/base/data-struct/list.h b/base/data-struct/list.h
index 54cb1c10b..e0a6256a4 100644
--- a/base/data-struct/list.h
+++ b/base/data-struct/list.h
@@ -1,7 +1,7 @@
#ifndef BASE_DATA_STRUCT_LIST_H
#define BASE_DATA_STRUCT_LIST_H
-#include <stddef.h> /* offsetof */
+#include "base/memory/container_of.h"
//----------------------------------------------------------------
@@ -100,7 +100,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
* contained in a structure of type t, return the containing structure.
*/
#define dm_list_struct_base(v, t, head) \
- ((t *)((const char *)(v) - offsetof(t, head)))
+ container_of(v, t, head)
/*
* Given the address v of an instance of 'struct dm_list list' contained in
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index 04100c0c1..191c44926 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -11,6 +11,8 @@
#ifndef _LVM_LVMLOCKD_INTERNAL_H
#define _LVM_LVMLOCKD_INTERNAL_H
+#include "base/memory/container_of.h"
+
#define MAX_NAME 64
#define MAX_ARGS 64
@@ -217,10 +219,6 @@ struct val_blk {
/* lm_unlock flags */
#define LMUF_FREE_VG 0x00000001
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;