Skip to content

Commit fe0b1e9

Browse files
arndbaxboe
authored andcommitted
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>
1 parent 7789bf0 commit fe0b1e9

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

drivers/block/drbd/drbd_state.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,9 +1542,10 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,
15421542

15431543
int notify_resource_state_change(struct sk_buff *skb,
15441544
unsigned int seq,
1545-
struct drbd_resource_state_change *resource_state_change,
1545+
void *state_change,
15461546
enum drbd_notification_type type)
15471547
{
1548+
struct drbd_resource_state_change *resource_state_change = state_change;
15481549
struct drbd_resource *resource = resource_state_change->resource;
15491550
struct resource_info resource_info = {
15501551
.res_role = resource_state_change->role[NEW],
@@ -1558,23 +1559,25 @@ int notify_resource_state_change(struct sk_buff *skb,
15581559

15591560
int notify_connection_state_change(struct sk_buff *skb,
15601561
unsigned int seq,
1561-
struct drbd_connection_state_change *connection_state_change,
1562+
void *state_change,
15621563
enum drbd_notification_type type)
15631564
{
1564-
struct drbd_connection *connection = connection_state_change->connection;
1565+
struct drbd_connection_state_change *p = state_change;
1566+
struct drbd_connection *connection = p->connection;
15651567
struct connection_info connection_info = {
1566-
.conn_connection_state = connection_state_change->cstate[NEW],
1567-
.conn_role = connection_state_change->peer_role[NEW],
1568+
.conn_connection_state = p->cstate[NEW],
1569+
.conn_role = p->peer_role[NEW],
15681570
};
15691571

15701572
return notify_connection_state(skb, seq, connection, &connection_info, type);
15711573
}
15721574

15731575
int notify_device_state_change(struct sk_buff *skb,
15741576
unsigned int seq,
1575-
struct drbd_device_state_change *device_state_change,
1577+
void *state_change,
15761578
enum drbd_notification_type type)
15771579
{
1580+
struct drbd_device_state_change *device_state_change = state_change;
15781581
struct drbd_device *device = device_state_change->device;
15791582
struct device_info device_info = {
15801583
.dev_disk_state = device_state_change->disk_state[NEW],
@@ -1585,9 +1588,10 @@ int notify_device_state_change(struct sk_buff *skb,
15851588

15861589
int notify_peer_device_state_change(struct sk_buff *skb,
15871590
unsigned int seq,
1588-
struct drbd_peer_device_state_change *p,
1591+
void *state_change,
15891592
enum drbd_notification_type type)
15901593
{
1594+
struct drbd_peer_device_state_change *p = state_change;
15911595
struct drbd_peer_device *peer_device = p->peer_device;
15921596
struct peer_device_info peer_device_info = {
15931597
.peer_repl_state = p->repl_state[NEW],
@@ -1605,8 +1609,8 @@ static void broadcast_state_change(struct drbd_state_change *state_change)
16051609
struct drbd_resource_state_change *resource_state_change = &state_change->resource[0];
16061610
bool resource_state_has_changed;
16071611
unsigned int n_device, n_connection, n_peer_device, n_peer_devices;
1608-
int (*last_func)(struct sk_buff *, unsigned int, void *,
1609-
enum drbd_notification_type) = NULL;
1612+
int (*last_func)(struct sk_buff *, unsigned int,
1613+
void *, enum drbd_notification_type) = NULL;
16101614
void *last_arg = NULL;
16111615

16121616
#define HAS_CHANGED(state) ((state)[OLD] != (state)[NEW])
@@ -1616,7 +1620,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)
16161620
})
16171621
#define REMEMBER_STATE_CHANGE(func, arg, type) \
16181622
({ FINAL_STATE_CHANGE(type | NOTIFY_CONTINUES); \
1619-
last_func = (typeof(last_func))func; \
1623+
last_func = func; \
16201624
last_arg = arg; \
16211625
})
16221626

drivers/block/drbd/drbd_state_change.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ extern void forget_state_change(struct drbd_state_change *);
4646

4747
extern int notify_resource_state_change(struct sk_buff *,
4848
unsigned int,
49-
struct drbd_resource_state_change *,
49+
void *,
5050
enum drbd_notification_type type);
5151
extern int notify_connection_state_change(struct sk_buff *,
5252
unsigned int,
53-
struct drbd_connection_state_change *,
53+
void *,
5454
enum drbd_notification_type type);
5555
extern int notify_device_state_change(struct sk_buff *,
5656
unsigned int,
57-
struct drbd_device_state_change *,
57+
void *,
5858
enum drbd_notification_type type);
5959
extern int notify_peer_device_state_change(struct sk_buff *,
6060
unsigned int,
61-
struct drbd_peer_device_state_change *,
61+
void *,
6262
enum drbd_notification_type type);
6363

6464
#endif /* DRBD_STATE_CHANGE_H */

0 commit comments

Comments
 (0)