Skip to contentSkip to conversation

hv_netvsc: Replace one-element array with flexible array member

PATCH Superseded Thorsten Blum 2 participants 3 messages Jan 16, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/net/hyperv/hyperv_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hyperv/hyperv_net.h +1 -1
index e690b95b1bbb..234db693cefa 100644
@@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
 	 *  LargeOffset                            SmallOffset
 	 */
 
-	struct nvsp_1_receive_buffer_section sections[1];
+	struct nvsp_1_receive_buffer_section sections[];
 } __packed;
 
 /*
Signature · 1 line
2.48.0
#1 lore raw
Quoted 14 lines · Thorsten Blum

Replace the deprecated one-element array with a modern flexible array member in the struct nvsp_1_message_send_receive_buffer_complete.

---
  drivers/net/hyperv/hyperv_net.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hyperv/hyperv_net.h +0 -0
index e690b95b1bbb..234db693cefa 100644

drivers/net/hyperv/hyperv_net.h struct nvsp_1_message_send_receive_buffer_complete { · line 470

Quoted 8 lines
drivers/net/hyperv/hyperv_net.h +1 -1
@@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
  	 *  LargeOffset                            SmallOffset
  	 */
 
-	struct nvsp_1_receive_buffer_section sections[1];
+	struct nvsp_1_receive_buffer_section sections[];
  } __packed;
 
  /*

1. How have you tested the change?

2. There is an instance of

sizeof(struct nvsp_1_message_send_receive_buffer_complete))

and your change decreases the size of the struct. Why do you think that is fine?

Signature · 2 lines
Thank you,
Roman
#2 lore raw
Quoted 13 lines · Roman Kisel
Quoted 12 lines · Thorsten Blum

Replace the deprecated one-element array with a modern flexible array member in the struct nvsp_1_message_send_receive_buffer_complete.

---
 drivers/net/hyperv/hyperv_net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/hyperv/hyperv_net.h +0 -0
index e690b95b1bbb..234db693cefa 100644
@@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
Quoted 8 lines

drivers/net/hyperv/hyperv_net.h struct nvsp_1_message_send_receive_buffer_complete { · line 470

Quoted 6 lines
drivers/net/hyperv/hyperv_net.h +1 -0
   *  LargeOffset                            SmallOffset
   */
 - struct nvsp_1_receive_buffer_section sections[1];
+ struct nvsp_1_receive_buffer_section sections[];
 } __packed;
   /*

1. How have you tested the change?

Compile-tested only.

Quoted 6 lines

2. There is an instance of

sizeof(struct nvsp_1_message_send_receive_buffer_complete))

and your change decreases the size of the struct. Why do you think that is fine?

Sorry, I actually changed this to struct_size_t(,,1), but forgot to add it to the commit - will submit a v2 shortly.

Thanks,
Thorsten