Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3748409rwb; Tue, 8 Nov 2022 08:01:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM5aCvjIM2XoIPR1N3GcybDhpdqtrW6HqrsrupqpOrG2Yia37WERH99ccjXF9ryDFC9/Wujj X-Received: by 2002:a17:903:2645:b0:185:480a:85d2 with SMTP id je5-20020a170903264500b00185480a85d2mr56957433plb.144.1667923280784; Tue, 08 Nov 2022 08:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667923280; cv=none; d=google.com; s=arc-20160816; b=B+n2ue/8/6eHDMnGS9cqdE4ftgupc17MBivu1Sp/KpK+9eBLtzmqXavaLNmnNZunt5 7T+4ACO8u31gMmR1oXBZxmieIyhX1OneXBq+ugW5F7Qb0qiSKI0ls5aWNhSeTZ1CubY0 CrybG8mS2Gc89lRQ/8rF+hUMYhC5QVi3v/ynQz705XY1fxiv0kRe8B1vIvWlMAR++SX7 6z8HVn0Mo6arLnj3KOxEXov/ngyVr7mJ9s2JbNHCXwk2Yen7acDz9lUXrK5b4ZQXKVL0 pqzb92W26EbNVLFjDuaOQTCrmpR1kWA+poZzndHWYdCXNVOmwhC24u/vrnsKm4bzsoKl q4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0lr43irSE6RKAyYW5HK8iSMY2B8ReYemMjJKZtW7jj8=; b=rOGq/fut8tNuiXL4Lpo9WIJEMnCDvP0Z15BqyvtCJjjboK+luxrMXYkPc0jyWfmJd3 9Tu+LnKOseBqiAEOOu6oThoccRYlRhTmVvTY93unzX/MEZmR323KDC+JAPNWXj+nnnop dGUDQiOaaGnTgm9vsFxVtTqbk68Zlvmv/a95GENRO+cEktGJW5r6u0/0pNF9o63I/PRn EoqJGQxqH7+u7DRr8qPuaUWbuLOsK1nR6gaLuPvm7KbUiExAmxg83TyG/81EEMFBO+qM NOUgyDNraCWyWLggyDWjNukUQy8ihsDTQv+krx5uv9MYGXx/wtDWjPx5wNqWhV++wTQj NPNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vLDabxVg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm24-20020a17090afa1800b00213587b200esi13038155pjb.189.2022.11.08.08.01.08; Tue, 08 Nov 2022 08:01:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vLDabxVg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234259AbiKHPey (ORCPT + 91 others); Tue, 8 Nov 2022 10:34:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234255AbiKHPeV (ORCPT ); Tue, 8 Nov 2022 10:34:21 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1868358BD1 for ; Tue, 8 Nov 2022 07:34:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C741AB81B3A for ; Tue, 8 Nov 2022 15:34:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02A06C433D7; Tue, 8 Nov 2022 15:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667921658; bh=QULdRw93pmvMhegOa4ePuSQURnFlXlrdf9tEjj03QEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vLDabxVgpbNTSTwEWB3ZHvOVjlO8SaGNBAcpiztSlSLwy7uH3nCw2udS/4Wus2EI3 553gkZ9ijOdEjlDteLyE+agQjchnFbdCpsTrsV6IOTd84rRivdmZHcKiYSd76/6Mse 33yNLzFtCtTN/aOWcjNQQAyfEqc/qi2w0iDOw5wU= Date: Tue, 8 Nov 2022 16:34:15 +0100 From: Greg Kroah-Hartman To: Deepak R Varma Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: staging/wlan-ng query: convert to flexible array member Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 08, 2022 at 08:42:59PM +0530, Deepak R Varma wrote: > 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? Are you sure they are unused? They look like structures that are read from the memory of a device, right? Try removing the structures from the union and see what happens :) thanks, greg k-h