summaryrefslogtreecommitdiff
path: root/base/memory/container_of.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/memory/container_of.h')
-rw-r--r--base/memory/container_of.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/base/memory/container_of.h b/base/memory/container_of.h
index 4e4c662bf..ddb795935 100644
--- a/base/memory/container_of.h
+++ b/base/memory/container_of.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+// Copyright (C) 2018 - 2020 Red Hat, Inc. All rights reserved.
//
// This file is part of LVM2.
//
@@ -13,10 +13,12 @@
#ifndef BASE_MEMORY_CONTAINER_OF_H
#define BASE_MEMORY_CONTAINER_OF_H
+#include <stddef.h> // offsetof
+
//----------------------------------------------------------------
#define container_of(v, t, head) \
- ((t *)((const char *)(v) - (const char *)&((t *) 0)->head))
+ ((t *)((const char *)(v) - offsetof(t, head)))
//----------------------------------------------------------------