[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220401075406.2407294-1-lv.ruyi@zte.com.cn>
Date: Fri, 1 Apr 2022 07:54:06 +0000
From: cgel.zte@...il.com
To: mike.marciniszyn@...nelisnetworks.com
Cc: dennis.dalessandro@...nelisnetworks.com, jgg@...pe.ca,
linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org,
Lv Ruyi <lv.ruyi@....com.cn>, Zeal Robot <zealci@....com.cn>
Subject: [PATCH] RDMA: Replace zero-length array with flexible-array member
From: Lv Ruyi <lv.ruyi@....com.cn>
There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should
no longer be used[2].
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@....com.cn>
---
drivers/infiniband/hw/hfi1/mad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 4146a2113a95..09fe0eb87884 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -2437,7 +2437,7 @@ struct opa_port_data_counters_msg {
__be64 port_vl_xmit_wait_data;
__be64 port_vl_rcv_bubble;
__be64 port_vl_mark_fecn;
- } vls[0];
+ } vls[];
/* array size defined by #bits set in vl_select_mask*/
} port[1]; /* array size defined by #ports in attribute modifier */
};
@@ -2470,7 +2470,7 @@ struct opa_port_error_counters64_msg {
u8 reserved3[7];
struct _vls_ectrs {
__be64 port_vl_xmit_discards;
- } vls[0];
+ } vls[];
/* array size defined by #bits set in vl_select_mask */
} port[1]; /* array size defined by #ports in attribute modifier */
};
--
2.25.1
Powered by blists - more mailing lists