Drivers: hv: Simplify data structures for VMBus channel close message
Subsystems (2)
PATCH 1/1 Drivers: hv: Simplify data structures for VMBus channel close message
From: Michael Kelley <[email protected]>
struct vmbus_close_msg is used for sending the VMBus channel close message. It contains a struct vmbus_channel_msginfo, which has a flex array member at the end. The latter's presence in the middle of struct vmbus_close_msg causes warnings when built with -Wflex-array-member-not-at-end.
But the struct vmbus_channel_msginfo is unused because the Hyper-V host does not send a response to the channel close message. So remove the struct vmbus_channel_msginfo. Then, since the only remaining field is struct vmbus_channel_close_channel, also remove the containing struct vmbus_close_msg and directly use struct vmbus_channel_close_channel. Besides eliminating unnecessary complexity, these changes resolve the -Wflex-array-member-not-at-end warnings.
--- drivers/hv/channel.c | 2 +- include/linux/hyperv.h | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/hv/channel.c +1 -1
@@ -925,7 +925,7 @@ static int vmbus_close_internal(struct vmbus_channel *channel)/* Send a closing message */ - msg = &channel->close_msg.msg; + msg = &channel->close_msg; msg->header.msgtype =CHANNELMSG_CLOSECHANNEL ; msg->child_relid = channel->offermsg.child_relid;
include/linux/hyperv.h +1 -6
@@ -707,11 +707,6 @@ struct vmbus_channel_msginfo {unsigned char msg[]; }; -struct vmbus_close_msg { -struct vmbus_channel_msginfo info; -struct vmbus_channel_close_channel msg; -}; -enum vmbus_device_type {HV_IDE =0 ,HV_SCSI ,
@@ -800,7 +795,7 @@ struct vmbus_channel {struct hv_ring_buffer_info outbound;/* send to parent */ struct hv_ring_buffer_info inbound;/* receive from parent */ -struct vmbus_close_msg close_msg; +struct vmbus_channel_close_channel close_msg;/* Statistics */ u64 interrupts;/* Host to Guest interrupts */
Signature · 1 line
2.25.1
Quoted 17 lines · On Mon, Sep 1, 2025 at 12:06 AM <[email protected]> wrote:
From: Michael Kelley <[email protected]>
struct
vmbus_close_msgis used for sending the VMBus channel close message. It contains a structvmbus_channel_msginfo, which has a flex array member at the end. The latter's presence in the middle of structvmbus_close_msgcauses warnings when built with -Wflex-array-member-not-at-end.But the struct
vmbus_channel_msginfois unused because the Hyper-V host does not send a response to the channel close message. So remove the structvmbus_channel_msginfo. Then, since the only remaining field is structvmbus_channel_close_channel, also remove the containing structvmbus_close_msgand directly use structvmbus_channel_close_channel. Besides eliminating unnecessary complexity, these changes resolve the -Wflex-array-member-not-at-end warnings.
Quoted 2 lines
Signed-off-by Michael Kelley <[email protected]>---
Signature · 2 lines
Thanks Tianyu Lan
Quoted 18 lines · Tianyu Lan
Quoted 17 lines · On Mon, Sep 1, 2025 at 12:06 AM <[email protected]> wrote:
From: Michael Kelley <[email protected]>
struct
vmbus_close_msgis used for sending the VMBus channel close message. It contains a structvmbus_channel_msginfo, which has a flex array member at the end. The latter's presence in the middle of structvmbus_close_msgcauses warnings when built with -Wflex-array-member-not-at-end.But the struct
vmbus_channel_msginfois unused because the Hyper-V host does not send a response to the channel close message. So remove the structvmbus_channel_msginfo. Then, since the only remaining field is structvmbus_channel_close_channel, also remove the containing structvmbus_close_msgand directly use structvmbus_channel_close_channel. Besides eliminating unnecessary complexity, these changes resolve the -Wflex-array-member-not-at-end warnings.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Michael Kelley <[email protected]>---
Reviewed-by Tianyu Lan <[email protected]>
Applied. Thanks.