wrappers: Avoid -Wcast-function-type warning
PATCH 1/1 wrappers: Avoid -Wcast-function-type warning
GCC emits this warning for mismatched function types unless the generic void (*) (void) signature is used ([1]) - e.g.:
warning: cast between incompatible function types from ‘int (*)(const char *)’ to ‘int (*)(void)’ [-Wcast-function-type]
[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wcast-function-type
Signed-off-by Philip Lorenz <[email protected]>
--- ports/linux/pseudo_wrappers.c | 4 ++-- pseudo_wrappers.c | 2 +- templates/wrapper_table | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-)
ports/linux/pseudo_wrappers.c +2 -2
@@ -96,7 +96,7 @@ syscall(long number, ...) {* guess about the number of args; the docs discuss calling conventions * up to 7, so let's try that? */ -void *res =__builtin_apply ((void (*)()) real_syscall,__builtin_apply_args (),sizeof (long ) *7 ); +void *res =__builtin_apply ((void (*)(void )) real_syscall,__builtin_apply_args (),sizeof (long ) *7 );__builtin_return (res); }
@@ -137,7 +137,7 @@ prctl(int option, ...) {* guess about the number of args; the docs discuss calling conventions * up to 5, so let's try that? */ -void *res =__builtin_apply ((void (*)()) real_prctl,__builtin_apply_args (),sizeof (long ) *5 ); +void *res =__builtin_apply ((void (*)(void )) real_prctl,__builtin_apply_args (),sizeof (long ) *5 );__builtin_return (res); }
pseudo_wrappers.c +1 -1
@@ -140,7 +140,7 @@ pseudo_init_one_wrapper(pseudo_function *func) {#endif f =dlsym (RTLD_NEXT , func->name);if (f) { - *func->real = f; + *func->real = (void (*)(void )) f; }/* it turns out that in some cases, we get apparently-harmless * errors if a function is missing, and that printing output
templates/wrapper_table +4 -4
@@ -6,8 +6,8 @@ * script if you want to modify this. */ typedef struct { char *name; /* the name */ - int (**real)(void); /* the underlying syscall */ - int (*wrapper)(void); /* the wrapper from guts/name.c */ + void (**real)(void); /* the underlying syscall */ + void (*wrapper)(void); /* the wrapper from guts/name.c */ char *version; /* the version, if we know and care */ } pseudo_function;
@@ -15,8 +15,8 @@ static pseudo_function pseudo_functions[] = { @body { /* ${comment}; */ "${name}${maybe_inode64}", - (int (**)(void)) &real_${name}, - (int (*)(void)) wrap_${name}, + (void (**)(void)) &real_${name}, + (void (*)(void)) wrap_${name}, ${version} }, @footer
Signature · 1 line
2.31.1