summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2020-03-04 16:07:22 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2020-03-05 17:38:55 +0100
commitb3fa71fbd8e583c040c04e655f3ebe70a3d941b2 (patch)
tree06444ffeddec0e0b453bec0ef78f74e5cd6420de /base
parent212cf8efbdc1c67f8ea85c951873b0fc3249eb07 (diff)
downloadlvm2-b3fa71fbd8e583c040c04e655f3ebe70a3d941b2.tar.gz
libdm: fix dm_list pointer arithmentic for new gcc 10 optimization
Diffstat (limited to 'base')
-rw-r--r--base/data-struct/list.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/base/data-struct/list.h b/base/data-struct/list.h
index 1a107d180..54cb1c10b 100644
--- a/base/data-struct/list.h
+++ b/base/data-struct/list.h
@@ -1,6 +1,8 @@
#ifndef BASE_DATA_STRUCT_LIST_H
#define BASE_DATA_STRUCT_LIST_H
+#include <stddef.h> /* offsetof */
+
//----------------------------------------------------------------
/*
@@ -98,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) - (const char *)&((t *) 0)->head))
+ ((t *)((const char *)(v) - offsetof(t, head)))
/*
* Given the address v of an instance of 'struct dm_list list' contained in
@@ -111,7 +113,7 @@ struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *e
* return another element f.
*/
#define dm_struct_field(v, t, e, f) \
- (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
+ (((t *)((uintptr_t)(v) - offsetof(t, e)))->f)
/*
* Given the address v of a known element e in a known structure of type t,