Skip to content

Commit 3df22e7

Browse files
tobluxkuba-moo
authored andcommitted
hv_netvsc: Replace one-element array with flexible array member
Replace the deprecated one-element array with a modern flexible array member in the struct nvsp_1_message_send_receive_buffer_complete. Use struct_size_t(,,1) instead of sizeof() to maintain the same size. Compile-tested only. Link: KSPP#79 Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Tested-by: Roman Kisel <romank@linux.microsoft.com> Reviewed-by: Roman Kisel <romank@linux.microsoft.com> Link: https://patch.msgid.link/20250116211932.139564-2-thorsten.blum@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2ce7289 commit 3df22e7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
464464
* LargeOffset SmallOffset
465465
*/
466466

467-
struct nvsp_1_receive_buffer_section sections[1];
467+
struct nvsp_1_receive_buffer_section sections[];
468468
} __packed;
469469

470470
/*

drivers/net/hyperv/netvsc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,8 @@ static void netvsc_send_completion(struct net_device *ndev,
866866

867867
case NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE:
868868
if (msglen < sizeof(struct nvsp_message_header) +
869-
sizeof(struct nvsp_1_message_send_receive_buffer_complete)) {
869+
struct_size_t(struct nvsp_1_message_send_receive_buffer_complete,
870+
sections, 1)) {
870871
netdev_err(ndev, "nvsp_msg1 length too small: %u\n",
871872
msglen);
872873
return;

0 commit comments

Comments
 (0)