Re: [PATCH] staging: wlan-ng: Use flexible-array for one / zero-length arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 28, 2022 at 06:08:13PM +0530, Deepak R Varma wrote:
> 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@xxxxxxxxx>
> ---
>  drivers/staging/wlan-ng/p80211mgmt.h  | 8 ++++----
>  drivers/staging/wlan-ng/p80211types.h | 2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/p80211mgmt.h b/drivers/staging/wlan-ng/p80211mgmt.h
> index 1ef30d3f3159..d6fe52de2c8f 100644
> --- a/drivers/staging/wlan-ng/p80211mgmt.h
> +++ b/drivers/staging/wlan-ng/p80211mgmt.h
> @@ -229,14 +229,14 @@ struct wlan_ie {
>  struct wlan_ie_ssid {
>  	u8 eid;
>  	u8 len;
> -	u8 ssid[1];		/* may be zero, ptrs may overlap */
> +	u8 ssid[];		/* may be zero, ptrs may overlap */
>  } __packed;

When you're writing this change look at where struct wlan_ie_ssid is
used.  It's included in five different structs:

	struct wlan_ie_ssid *ssid;

But none of those *ssid pointers are used.  So instead of doing this
just delete the wlan_ie_ssid struct and delete every reference to it.
Send that as a patch by itself and then repeat that process for the next
struct.

regards,
dan carpenter





[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux