summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2020-03-05 12:58:34 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2020-03-05 17:38:55 +0100
commitf439716b7583556352f1b7a6696ada32f52e44b4 (patch)
tree917f503eebc9115a44eb1992d316e0246b6f84a7 /base
parentb3fa71fbd8e583c040c04e655f3ebe70a3d941b2 (diff)
downloadlvm2-f439716b7583556352f1b7a6696ada32f52e44b4.tar.gz
container_of: use offsetof from stddef
Use standardized offsetof() macro from stddef. Helps to build valid code with latest gcc10 with -O2.
Diffstat (limited to 'base')
-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)))
//----------------------------------------------------------------