Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on sparc with -Wcast-align #147

Closed
floppym opened this issue Sep 12, 2021 · 2 comments
Closed

Build failure on sparc with -Wcast-align #147

floppym opened this issue Sep 12, 2021 · 2 comments

Comments

@floppym
Copy link
Contributor

floppym commented Sep 12, 2021

This was reported by a user on Gentoo Linux (sparc).

https://bugs.gentoo.org/812461

The user has -Wcast-align in CFLAGS, and this gets converted to an error by the -Werror parameter configured in the project arguments.

It might be worth addressing the alignment issue.

FAILED: libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o 
sparc-unknown-linux-gnu-gcc -Ilibumockdev-preload.so.0.0.0.p -I. -I../umockdev-0.16.1 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -Werror=missing-prototypes -Werror=strict-prototypes -Werror=nested-externs -Werror=pointer-arith -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=unused-variable -Werror=return-type -Werror=uninitialized -O2 -mcpu=niagara2 -pipe -Wcast-align -fPIC -fvisibility=default -MD -MQ libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o -MF libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o.d -o libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o -c ../umockdev-0.16.1/src/libumockdev-preload.c
../umockdev-0.16.1/src/libumockdev-preload.c: In function ?netlink_recvmsg?:
../umockdev-0.16.1/src/libumockdev-preload.c:418:27: error: cast increases required alignment of target type [-Werror=cast-align]
  418 |      struct ucred *cred = (struct ucred *)CMSG_DATA(cmsg);
      |                           ^
cc1: all warnings being treated as errors
@martinpitt
Copy link
Owner

On Debian sparc64, tests fail with SIGBUS. This may or may not be related.

@martinpitt
Copy link
Owner

FTR, the Debian sparc failure is unrelated. Getting this code wrong fails tests/test-umockdev.c t_testbed_add_devicev(), not test-umockdev-vala.

This is annoying to "fix": the code can't just use memcpy() into an actually declared struct, as "real" code would do, as it really needs to modify the existing msg from the wrapped netlink_recvmsg(). I'll try to come up with something using memcpy()'ing an uid_t into the message with offsetof().

martinpitt added a commit that referenced this issue Sep 12, 2021
To make errors like #147 more obvious. This does not cause any warnings
on x86, though.
martinpitt added a commit that referenced this issue Sep 12, 2021
To make errors like #147 more obvious. This does not cause any warnings
on x86, though.
martinpitt added a commit that referenced this issue Sep 12, 2021
Casting the netlink CMSG_DATA into a `struct ucred` increases the
required alignment on at least sparc. Move to memcpy() instead.

Fixes #147
martinpitt added a commit that referenced this issue Sep 12, 2021
To make errors like #147 more obvious. This does not cause any warnings
on x86, though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants