From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C42CC433FE for ; Tue, 8 Nov 2022 15:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbiKHPNd (ORCPT ); Tue, 8 Nov 2022 10:13:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234312AbiKHPNZ (ORCPT ); Tue, 8 Nov 2022 10:13:25 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB7A52887 for ; Tue, 8 Nov 2022 07:13:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667920385; bh=sejP4aBDdhMo3HG9Xhj2vvP0zlb9qbq1zHjDd4eRHUM=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=ZuiOdBdjtkEIP+oN7dr8IVxqYOpsonyeISX+DbXtTEo1QPmbjl5am5DM8za3qZ0YY hwaGCcfhBAUEM4DKUfgUUCHhTIDXJ6Iw9CUsAipf/cfzP5aMAKLYAaDEnmnAuYnxB4 4crHcJX4yRfHt2doHIiidtWeZ+qN/DXubq635474= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 8 Nov 2022 16:13:05 +0100 (CET) X-EA-Auth: OlqpyWd3qQcgdjOz9yJAVFrkj87A1WXK9JgBsKUSYg+jqfeXlddkMDsowDf2k8clG2dGPZ5qCVS6zAKNw6gfGH2vXDnrj/ry Date: Tue, 8 Nov 2022 20:42:59 +0530 From: Deepak R Varma To: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: staging/wlan-ng query: convert to flexible array member Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, First, my apologies for the long email. I am requesting guidance on how to approach resolving the zero element flexible VLO struct implementation in this driver in file drivers/staging/waln-ng/hfa384x.f The struct hfa384x_pdrec contains nested structs with zero element arrays. These zero element structs are part of a union 'data' inside the struct container. This union 'data' is the last element of this container. Please see the code snip below: 1068 struct hfa384x_pdrec { 1 __le16 len; /* in words */ 2 __le16 code; 3 union pdr { 4 struct hfa384x_pdr_pcb_partnum pcb_partnum; 11 struct hfa384x_pdr_nicid nicid; 12 struct hfa384x_pdr_refdac_measurements refdac_measurements; 13 struct hfa384x_pdr_vgdac_measurements vgdac_measurements; 14 struct hfa384x_pdr_level_comp_measurements level_compc_measurements; 15 struct hfa384x_pdr_mac_address mac_address; 39 } data; 40 } __packed; The three structures in question are declared as follows in the same file: 962 struct hfa384x_pdr_refdac_measurements { 1 u16 value[0]; 2 } __packed; 3 4 struct hfa384x_pdr_vgdac_measurements { 5 u16 value[0]; 6 } __packed; 7 8 struct hfa384x_pdr_level_comp_measurements { 9 u16 value[0]; 10 } __packed; As per the C99 specifications, the flexible array struct should have at least one member other than the true flexible array member. So converting these from [0] to [] is not feasible in the current form. I did not find these struct variables being used for memory allocation in the code directly. My find may be short since the implementation appears to get very complex as I tried to get deeper. Can you please suggest how should I approach correcting the zero element flex array implementation here? Can these structs be removed if they are unused? Thank you. ./drv