wifi: hostap: Avoid clashing function prototypes
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 8 Nov 2022 20:25:17 +0000 (14:25 -0600)
committerKalle Valo <kvalo@kernel.org>
Wed, 16 Nov 2022 09:31:47 +0000 (11:31 +0200)
commitfd7ef879a9835f9374fd611f2d6118e4a8f9b919
tree4dcf79731ef2d52eefd57461deb9c67b7d8132eb
parent02ae6a7034d7b2e3d89e33d73da10a1f156789a0
wifi: hostap: Avoid clashing function prototypes

When built with Control Flow Integrity, function prototypes between
caller and function declaration must match. These mismatches are visible
at compile time with the new -Wcast-function-type-strict in Clang[1].

Fix a total of 42 warnings like these:

../drivers/net/wireless/intersil/hostap/hostap_ioctl.c:3868:2: warning: cast from 'int (*)(struct net_device *, struct iw_request_info *, char *, char *)' to 'iw_handler' (aka 'int (*)(struct net_device *, struct iw_request_info *, union iwreq_data *, char *)') converts to incompatible function type [-Wcast-function-type-strict]
        (iw_handler) prism2_get_name,                   /* SIOCGIWNAME */
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

The hostap Wireless Extension handler callbacks (iw_handler) use a
union for the data argument. Actually use the union and perform explicit
member selection in the function body instead of having a function
prototype mismatch. There are no resulting binary differences
before/after changes.

These changes were made partly manually and partly with the help of
Coccinelle.

Link: https://github.com/KSPP/linux/issues/235
Link: https://reviews.llvm.org/D134831
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/e480e7713f1a4909ae011068c8d793cc4a638fbd.1667934775.git.gustavoars@kernel.org
drivers/net/wireless/intersil/hostap/hostap_ioctl.c