• Kir Kolyshkin's avatar
    zdtm: compile fix for clang · 3c75cf51
    Kir Kolyshkin authored
    clang complains about an unused function:
    
    > clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
    > -iquote ./arch/x86/include  -c -o parseargs.o parseargs.c
    > parseargs.c:12:1: error: unused function '__check_help'
    > [-Werror,-Wunused-function]
    > TEST_OPTION(help, bool, "print help message and exit", 0);
    > ^
    > ./zdtmtst.h:71:2: note: expanded from macro 'TEST_OPTION'
    >         param_check_##type(name, &(name));
    > \
    >         ^
    > <scratch space>:46:1: note: expanded from here
    > param_check_bool
    > ^
    > ./zdtmtst.h:84:35: note: expanded from macro 'param_check_bool'
    > #define param_check_bool(name, p) __param_check(name, p, int)
    >                                   ^
    > ./zdtmtst.h:78:22: note: expanded from macro '__param_check'
    >         static inline type *__check_##name(void) { return(p); }
    >                             ^
    > <scratch space>:47:1: note: expanded from here
    > __check_help
    > ^
    > 1 error generated.
    > <builtin>: recipe for target 'parseargs.o' failed
    
    As far as I can tell, the functions __check_##name are generated in
    order to check the argument type by the compiler.
    
    For gcc, the "inline" keyword is enough to suppress the "unused function"
    warning even when -Wunused-function is used. For clang, it's not the
    case (see https://llvm.org/bugs/show_bug.cgi?id=22712).
    
    A way to "use" the function is to use its name as a pointer and cast it
    to void. This is what this patch does.
    Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    3c75cf51
Name
Last commit
Last update
Documentation Loading commit data...
contrib Loading commit data...
coredump Loading commit data...
crit Loading commit data...
criu Loading commit data...
images Loading commit data...
lib Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
INSTALL.md Loading commit data...
Makefile Loading commit data...
Makefile.install Loading commit data...
Makefile.versions Loading commit data...
README.md Loading commit data...