[CRIU] [PATCH 1/2] Silence clang-4 warning about unaligned pointer
Kir Kolyshkin
kolyshkin at gmail.com
Sat Sep 30 10:47:41 MSK 2017
This is what we have:
> compel/src/lib/infect.c:1145:38: error: taking address of packed member
> 'uc_sigmask' of class or structure 'ucontext_ia32' may result in an
> unaligned pointer value [-Werror,-Waddress-of-packed-member]
> blk_sigset = RT_SIGFRAME_UC_SIGMASK(f);
> ~~~~~~~~~~~~~~~~~~~~~~~^~
> compel/include/uapi/asm/sigframe.h:133:4: note: expanded from macro
> 'RT_SIGFRAME_UC_SIGMASK'
> (&rt_sigframe->compat.uc.uc_sigmask))
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
Indeed this results in an unaligned pointer, but as this is intended and
well known (see commit dd6736bd "compel/x86/compat: pack ucontext_ia32"),
we need to silence the warning here.
For more details, see https://reviews.llvm.org/D20561
While at it, remove extra (also outdated and unused) declaration of
RT_SIGFRAME_UC_SIGMASK macro.
Originally found by Travis on Alpine Linux, reproduced on Ubuntu 17.10.
Reported-by: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kolyshkin at gmail.com>
---
compel/arch/x86/src/lib/include/uapi/asm/sigframe.h | 2 +-
compel/src/lib/infect.c | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
index 2b51c366..3260d9c1 100644
--- a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
+++ b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h
@@ -130,7 +130,7 @@ struct rt_sigframe {
#define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) \
((rt_sigframe->is_native) ? \
(&rt_sigframe->native.uc.uc_sigmask) : \
- (&rt_sigframe->compat.uc.uc_sigmask))
+ ((k_rtsigset_t *)(void *)&rt_sigframe->compat.uc.uc_sigmask))
#define RT_SIGFRAME_REGIP(rt_sigframe) \
((rt_sigframe->is_native) ? \
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index 07200a7a..2f608a02 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -1124,11 +1124,6 @@ static int save_regs_plain(void *to, user_regs_struct_t *r, user_fpregs_struct_t
return 0;
}
-#ifndef RT_SIGFRAME_UC_SIGMASK
-#define RT_SIGFRAME_UC_SIGMASK(sigframe) \
- (k_rtsigset_t*)&RT_SIGFRAME_UC(sigframe)->uc_sigmask
-#endif
-
static int make_sigframe_plain(void *from, struct rt_sigframe *f, struct rt_sigframe *rtf, k_rtsigset_t *b)
{
struct plain_regs_struct *prs = from;
--
2.14.1
More information about the CRIU
mailing list