martinpitt / umockdev

Mock hardware devices for creating unit tests and bug reporting
https://launchpad.net/umockdev
GNU Lesser General Public License v2.1
308 stars 55 forks source link

0.15.3 - error: cast to smaller integer type 'enum script_record_format' from 'const void #116

Closed AngryPenguinPL closed 3 years ago

AngryPenguinPL commented 3 years ago

When compile 0.15.3 I see this error: cast to smaller integer type 'enum script_record_format' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast] Worth to add 0.14.1 compile without issues.

OS OpenMandriva Cooker Compiler: Clang 11

Build log with error:

FAILED: libumockdev-preload.so.0.0.0.p/src_libumockdev-preload.c.o 
DEBUG util.py:623:  /usr/bin/clang -Ilibumockdev-preload.so.0.0.0.p -I. -I.. -Xclang -fcolor-diagnostics -pipe -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 -Os -fomit-frame-pointer -g1 -Wstrict-aliasing=2 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -m64 -mtune=generic -flto -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 ../src/libumockdev-preload.c
DEBUG util.py:623:  ../src/libumockdev-preload.c:912:11: error: cast to smaller integer type 'enum script_record_format' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
DEBUG util.py:623:      fmt = (enum script_record_format) data;
DEBUG util.py:623:            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEBUG util.py:623:  1 error generated.

Full build log: http://file-store.openmandriva.org/api/v1/file_stores/cbc3df2ad478ee72b3ae2454b6ca821351c59bbd.log?show=true

martinpitt commented 3 years ago

This line was added in 2014 in commit 95b65647e0d1, so I rather suspect it's some new clang version that causes the new warning?

Anyway, I can reproduce this with clang on Fedora, I'll add that to CI and fix it, thanks for the report!