diff options
author | Stewart Smith <stewart@linux.ibm.com> | 2019-06-13 11:41:21 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.ibm.com> | 2019-06-13 11:41:21 +1000 |
commit | df9d972c23086bc26efecc7519f008efab791419 (patch) | |
tree | 39f28cd99f2e412b47054ba62dce6464c470d95f /include/opal-internal.h | |
parent | 16aa1b111ed0183838acab7c295c198d344016a1 (diff) | |
download | skiboot-df9d972c23086bc26efecc7519f008efab791419.zip skiboot-df9d972c23086bc26efecc7519f008efab791419.tar.gz skiboot-df9d972c23086bc26efecc7519f008efab791419.tar.bz2 |
sparse: fix OPAL API function argument test
This is based on a patch from Cédric from way back in 2015 (probably
around the time we split opal.h into opal-api.h and opal-internal.h)
that for some reason never got merged.
It means that false warnings spat out of sparse due to our crazy-ass
macro usage get silenced.
It fixes warnings such as
"Using plain integer as NULL pointer"
when the prototype of the function is tested with the __test_args#
defines.
Suggested-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'include/opal-internal.h')
-rw-r--r-- | include/opal-internal.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/opal-internal.h b/include/opal-internal.h index 60d7f7b..448f4b5 100644 --- a/include/opal-internal.h +++ b/include/opal-internal.h @@ -28,10 +28,17 @@ struct opal_table_entry { u32 nargs; }; +#ifdef __CHECKER__ +#define __opal_func_test_arg(__func, __nargs) 0 +#else +#define __opal_func_test_arg(__func, __nargs) \ + sizeof(__func( __test_args##__nargs )) +#endif + #define opal_call(__tok, __func, __nargs) \ static struct opal_table_entry __e_##__func __used __section(".opal_table") = \ { .func = __func, .token = __tok, \ - .nargs = __nargs + 0 * sizeof(__func( __test_args##__nargs )) } + .nargs = __nargs + 0 * __opal_func_test_arg(__func, __nargs) } /* Make sure function takes args they claim. Look away now... */ #define __test_args0 @@ -57,7 +64,7 @@ void opal_dynamic_event_free(__be64 event); extern void add_opal_node(void); #define opal_register(token, func, nargs) \ - __opal_register((token) + 0*sizeof(func(__test_args##nargs)), \ + __opal_register((token) + 0*__opal_func_test_arg(func, nargs), \ (func), (nargs)) extern void __opal_register(uint64_t token, void *func, unsigned num_args); |