From: Thomas Weißschuh Date: Fri, 12 Jan 2024 06:51:39 +0000 (+0100) Subject: include/c.h: handle members of const struct X-Git-Tag: v2.40-rc1~51^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24fce5a36c2cb126f3fc27b34ba368f94941c039;p=thirdparty%2Futil-linux.git include/c.h: handle members of const struct Trying to copy into a local const struct will lead to a compiler error. By adding a "+ 0" to the argument of __typeof__() the type of the resulting express will loose its constness. Signed-off-by: Thomas Weißschuh --- diff --git a/include/c.h b/include/c.h index 36eb2a9e7f..e353643fdd 100644 --- a/include/c.h +++ b/include/c.h @@ -215,7 +215,7 @@ #define read_unaligned_member(p, m) __extension__ ({ \ size_t offset = offsetof(__typeof__(* p), m); \ - __typeof__(p->m) v; \ + __typeof__(p->m + 0) v; \ memcpy(&v, ((unsigned char *)p) + offset, sizeof(v)); \ v; })