mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 08:35:19 -05:00
drbd: fix function cast warnings in state machine
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); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Change these all to actually expect a void pointer to be passed, which matches the caller. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20240213100354.457128-1-arnd@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
7789bf0552
commit
fe0b1e9a73
2 changed files with 18 additions and 14 deletions
|
@ -1542,9 +1542,10 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,
|
||||||
|
|
||||||
int notify_resource_state_change(struct sk_buff *skb,
|
int notify_resource_state_change(struct sk_buff *skb,
|
||||||
unsigned int seq,
|
unsigned int seq,
|
||||||
struct drbd_resource_state_change *resource_state_change,
|
void *state_change,
|
||||||
enum drbd_notification_type type)
|
enum drbd_notification_type type)
|
||||||
{
|
{
|
||||||
|
struct drbd_resource_state_change *resource_state_change = state_change;
|
||||||
struct drbd_resource *resource = resource_state_change->resource;
|
struct drbd_resource *resource = resource_state_change->resource;
|
||||||
struct resource_info resource_info = {
|
struct resource_info resource_info = {
|
||||||
.res_role = resource_state_change->role[NEW],
|
.res_role = resource_state_change->role[NEW],
|
||||||
|
@ -1558,13 +1559,14 @@ int notify_resource_state_change(struct sk_buff *skb,
|
||||||
|
|
||||||
int notify_connection_state_change(struct sk_buff *skb,
|
int notify_connection_state_change(struct sk_buff *skb,
|
||||||
unsigned int seq,
|
unsigned int seq,
|
||||||
struct drbd_connection_state_change *connection_state_change,
|
void *state_change,
|
||||||
enum drbd_notification_type type)
|
enum drbd_notification_type type)
|
||||||
{
|
{
|
||||||
struct drbd_connection *connection = connection_state_change->connection;
|
struct drbd_connection_state_change *p = state_change;
|
||||||
|
struct drbd_connection *connection = p->connection;
|
||||||
struct connection_info connection_info = {
|
struct connection_info connection_info = {
|
||||||
.conn_connection_state = connection_state_change->cstate[NEW],
|
.conn_connection_state = p->cstate[NEW],
|
||||||
.conn_role = connection_state_change->peer_role[NEW],
|
.conn_role = p->peer_role[NEW],
|
||||||
};
|
};
|
||||||
|
|
||||||
return notify_connection_state(skb, seq, connection, &connection_info, type);
|
return notify_connection_state(skb, seq, connection, &connection_info, type);
|
||||||
|
@ -1572,9 +1574,10 @@ int notify_connection_state_change(struct sk_buff *skb,
|
||||||
|
|
||||||
int notify_device_state_change(struct sk_buff *skb,
|
int notify_device_state_change(struct sk_buff *skb,
|
||||||
unsigned int seq,
|
unsigned int seq,
|
||||||
struct drbd_device_state_change *device_state_change,
|
void *state_change,
|
||||||
enum drbd_notification_type type)
|
enum drbd_notification_type type)
|
||||||
{
|
{
|
||||||
|
struct drbd_device_state_change *device_state_change = state_change;
|
||||||
struct drbd_device *device = device_state_change->device;
|
struct drbd_device *device = device_state_change->device;
|
||||||
struct device_info device_info = {
|
struct device_info device_info = {
|
||||||
.dev_disk_state = device_state_change->disk_state[NEW],
|
.dev_disk_state = device_state_change->disk_state[NEW],
|
||||||
|
@ -1585,9 +1588,10 @@ int notify_device_state_change(struct sk_buff *skb,
|
||||||
|
|
||||||
int notify_peer_device_state_change(struct sk_buff *skb,
|
int notify_peer_device_state_change(struct sk_buff *skb,
|
||||||
unsigned int seq,
|
unsigned int seq,
|
||||||
struct drbd_peer_device_state_change *p,
|
void *state_change,
|
||||||
enum drbd_notification_type type)
|
enum drbd_notification_type type)
|
||||||
{
|
{
|
||||||
|
struct drbd_peer_device_state_change *p = state_change;
|
||||||
struct drbd_peer_device *peer_device = p->peer_device;
|
struct drbd_peer_device *peer_device = p->peer_device;
|
||||||
struct peer_device_info peer_device_info = {
|
struct peer_device_info peer_device_info = {
|
||||||
.peer_repl_state = p->repl_state[NEW],
|
.peer_repl_state = p->repl_state[NEW],
|
||||||
|
@ -1605,8 +1609,8 @@ static void broadcast_state_change(struct drbd_state_change *state_change)
|
||||||
struct drbd_resource_state_change *resource_state_change = &state_change->resource[0];
|
struct drbd_resource_state_change *resource_state_change = &state_change->resource[0];
|
||||||
bool resource_state_has_changed;
|
bool resource_state_has_changed;
|
||||||
unsigned int n_device, n_connection, n_peer_device, n_peer_devices;
|
unsigned int n_device, n_connection, n_peer_device, n_peer_devices;
|
||||||
int (*last_func)(struct sk_buff *, unsigned int, void *,
|
int (*last_func)(struct sk_buff *, unsigned int,
|
||||||
enum drbd_notification_type) = NULL;
|
void *, enum drbd_notification_type) = NULL;
|
||||||
void *last_arg = NULL;
|
void *last_arg = NULL;
|
||||||
|
|
||||||
#define HAS_CHANGED(state) ((state)[OLD] != (state)[NEW])
|
#define HAS_CHANGED(state) ((state)[OLD] != (state)[NEW])
|
||||||
|
@ -1616,7 +1620,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)
|
||||||
})
|
})
|
||||||
#define REMEMBER_STATE_CHANGE(func, arg, type) \
|
#define REMEMBER_STATE_CHANGE(func, arg, type) \
|
||||||
({ FINAL_STATE_CHANGE(type | NOTIFY_CONTINUES); \
|
({ FINAL_STATE_CHANGE(type | NOTIFY_CONTINUES); \
|
||||||
last_func = (typeof(last_func))func; \
|
last_func = func; \
|
||||||
last_arg = arg; \
|
last_arg = arg; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -46,19 +46,19 @@ extern void forget_state_change(struct drbd_state_change *);
|
||||||
|
|
||||||
extern int notify_resource_state_change(struct sk_buff *,
|
extern int notify_resource_state_change(struct sk_buff *,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
struct drbd_resource_state_change *,
|
void *,
|
||||||
enum drbd_notification_type type);
|
enum drbd_notification_type type);
|
||||||
extern int notify_connection_state_change(struct sk_buff *,
|
extern int notify_connection_state_change(struct sk_buff *,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
struct drbd_connection_state_change *,
|
void *,
|
||||||
enum drbd_notification_type type);
|
enum drbd_notification_type type);
|
||||||
extern int notify_device_state_change(struct sk_buff *,
|
extern int notify_device_state_change(struct sk_buff *,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
struct drbd_device_state_change *,
|
void *,
|
||||||
enum drbd_notification_type type);
|
enum drbd_notification_type type);
|
||||||
extern int notify_peer_device_state_change(struct sk_buff *,
|
extern int notify_peer_device_state_change(struct sk_buff *,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
struct drbd_peer_device_state_change *,
|
void *,
|
||||||
enum drbd_notification_type type);
|
enum drbd_notification_type type);
|
||||||
|
|
||||||
#endif /* DRBD_STATE_CHANGE_H */
|
#endif /* DRBD_STATE_CHANGE_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue