From 8f3d2d5e11305b5f3fc7ced7bd2f81412c9e7d93 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 4 Mar 2020 16:07:22 +0100 Subject: [PATCH] libdm: fix dm_list pointer arithmentic for new gcc 10 optimization --- libdm/libdevmapper.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 18fe9f9fd..03a43eb45 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -30,6 +30,7 @@ #include #include #include +#include /* offsetof */ #ifndef __GNUC__ # define __typeof__ typeof @@ -2470,7 +2471,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 @@ -2483,7 +2484,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,