public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: Use flexible-array for one length array member
@ 2022-10-28 12:56 Deepak R Varma
  2022-10-28 14:03 ` Pavel Skripkin
  0 siblings, 1 reply; 7+ messages in thread
From: Deepak R Varma @ 2022-10-28 12:56 UTC (permalink / raw)
  To: outreachy, Larry Finger, Phillip Potter, Pavel Skripkin,
	Greg Kroah-Hartman, linux-staging, linux-kernel

Flexible-array member should be used instead of one or zero member to
meet the need for having a dynamically sized trailing elements in a
structure. Refer to links [1] and [2] for detailed guidance on this
suggestion.

[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

Issue identified using coccicheck.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/staging/r8188eu/include/odm.h         | 2 +-
 drivers/staging/r8188eu/include/wlan_bssdef.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h
index 89b01dd614ba..e2a9de5b9323 100644
--- a/drivers/staging/r8188eu/include/odm.h
+++ b/drivers/staging/r8188eu/include/odm.h
@@ -166,7 +166,7 @@ struct odm_ra_info {

 struct ijk_matrix_regs_set {
 	bool	bIQKDone;
-	s32	Value[1][IQK_Matrix_REG_NUM];
+	s32	Value[][IQK_Matrix_REG_NUM];
 };

 struct odm_rf_cal {
diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h
index 831c465df500..33177de194eb 100644
--- a/drivers/staging/r8188eu/include/wlan_bssdef.h
+++ b/drivers/staging/r8188eu/include/wlan_bssdef.h
@@ -179,7 +179,7 @@ struct ndis_802_11_status_ind {

 struct ndis_802_11_auth_evt {
 	struct ndis_802_11_status_ind       Status;
-	struct ndis_802_11_auth_req  Request[1];
+	struct ndis_802_11_auth_req  Request[];
 };

 struct ndis_802_11_test {
@@ -291,7 +291,7 @@ struct pmkid_candidate {
 struct ndis_802_11_pmkid_list {
 	u32 Version;       /*  Version of the structure */
 	u32 NumCandidates; /*  No. of pmkid candidates */
-	struct pmkid_candidate CandidateList[1];
+	struct pmkid_candidate CandidateList[];
 };

 struct ndis_802_11_auth_encrypt {
@@ -304,7 +304,7 @@ struct ndis_802_11_cap {
 	u32  Version;
 	u32  NoOfPMKIDs;
 	u32  NoOfAuthEncryptPairsSupported;
-	struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[1];
+	struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[];
 };

 u8 key_2char2num(u8 hch, u8 lch);
--
2.34.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-03  5:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-28 12:56 [PATCH] staging: r8188eu: Use flexible-array for one length array member Deepak R Varma
2022-10-28 14:03 ` Pavel Skripkin
2022-10-28 14:11   ` Deepak R Varma
2022-10-28 14:43     ` Dan Carpenter
2022-11-02 19:19       ` Deepak R Varma
2022-11-03  5:22         ` Dan Carpenter
2022-11-03  5:25           ` Deepak R Varma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox