Re: [PATCH] drbd: fix function cast warnings in state machine

From: Jens Axboe
Date: Tue Feb 13 2024 - 10:56:14 EST



On Tue, 13 Feb 2024 11:03:01 +0100, Arnd Bergmann wrote:
> There are four state machines in drbd that use a common infrastructure, with
> a cast to an incompatible function type in REMEMBER_STATE_CHANGE that clang-16
> now warns about:
>
> drivers/block/drbd/drbd_state.c:1632:3: error: cast from 'int (*)(struct sk_buff *, unsigned int, struct drbd_resource_state_change *, enum drbd_notification_type)' to 'typeof (last_func)' (aka 'int (*)(struct sk_buff *, unsigned int, void *, enum drbd_notification_type)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
> 1632 | REMEMBER_STATE_CHANGE(notify_resource_state_change,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1633 | resource_state_change, NOTIFY_CHANGE);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/block/drbd/drbd_state.c:1619:17: note: expanded from macro 'REMEMBER_STATE_CHANGE'
> 1619 | last_func = (typeof(last_func))func; \
> | ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/block/drbd/drbd_state.c:1641:4: error: cast from 'int (*)(struct sk_buff *, unsigned int, struct drbd_connection_state_change *, enum drbd_notification_type)' to 'typeof (last_func)' (aka 'int (*)(struct sk_buff *, unsigned int, void *, enum drbd_notification_type)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
> 1641 | REMEMBER_STATE_CHANGE(notify_connection_state_change,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1642 | connection_state_change, NOTIFY_CHANGE);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> [...]

Applied, thanks!

[1/1] drbd: fix function cast warnings in state machine
commit: fe0b1e9a73d60f01fdc391925be74e823af7c91d

Best regards,
--
Jens Axboe