Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14430980rwb; Mon, 28 Nov 2022 00:23:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kmXQuZgNhtdUlvjNIDt1qbg1uP6T0RFBuLqwIgSJZkutZuhoqSjuFzP6JoF5DZFg4TOOR X-Received: by 2002:a17:906:9f09:b0:7bc:db1b:206f with SMTP id fy9-20020a1709069f0900b007bcdb1b206fmr12134619ejc.719.1669623835575; Mon, 28 Nov 2022 00:23:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669623835; cv=none; d=google.com; s=arc-20160816; b=XbE780oB0rDHsge50qMRrTaKUpt51VCGFiZnH+liVg03YInWOq9EwViauWimCTvvi/ Q343gMRYcBBZcRd2jTgrXx8y+PnuxDbOgvGqj1ueFDvcA4vsO6qLz6q84kW3dLwSSTm8 +RKmfR33gjF/DjMEI0wK2CpAc3r6eoQ4zhhvAv2plVFMlO2VhsRay8uI4Lv5P2mwDOaj T6fQwR7xkF+hqzpeRuO0BXc9lJmZIAVNabqGNUq7dxKRUaA3u8H5+ZLBzimTo8sxJg0y xyhWNxtSA4XXBuwZaSE70ymaWFyhsE3hKecxLcY/UGAhZfI+EVtGdt2U9m7JO3FJNCyy Qw+A== 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=55Yoxcq3+d/tHhqKEtTkuDqeutda58+RH9+uCLxHdaU=; b=IDYiPTYbC1tzVrdV41IZWGqozNiImphPp4+PnpE0sn3kpYSpCRQuCwvrEIkDIxJ9kC APZvFDINK181O1zJxwcWFMlTDVDSvBnncH7umgp/z2thmmhYxvg4VPeVUu58axTjgidr W4zvkC052gc9kkgKJtjS8e45DgEXf/4SxteuGRUp9YNbV9pkTCU3GrlZU4MVv29KMt2w /JdQA6n0LPlIibsi9YlBxkXbRyuMfyQ0z6x4todHaVfnJUcL0NjNY9B+ME3NhTBbyXkk Rpb1DRcQ+pM8Elw3fCxesrkjBb9+kly+IExtC8xxZl5U7l/HmC3tdoha+1PMZ/BOV3gt EMFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KDr4QKS5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020a05640211d400b00469634340b4si8804892edw.285.2022.11.28.00.23.35; Mon, 28 Nov 2022 00:23:55 -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=@gmail.com header.s=20210112 header.b=KDr4QKS5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbiK1Hu0 (ORCPT + 83 others); Mon, 28 Nov 2022 02:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiK1HuZ (ORCPT ); Mon, 28 Nov 2022 02:50:25 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995F51580E for ; Sun, 27 Nov 2022 23:50:24 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bx10so3271269wrb.0 for ; Sun, 27 Nov 2022 23:50:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=55Yoxcq3+d/tHhqKEtTkuDqeutda58+RH9+uCLxHdaU=; b=KDr4QKS5v9Wzz/FasCrhsx3fWubdC8WFqhJci6NolcG7farx4GD8o4IryNQQxTGjW5 cviPRTyGbAHLEOKoPjjqHakjocoeVVXr6kYl4Ffu5CLLX8Oii8P5BDbpTo8oIzZYjc5D UU6JmZVG+iPQ9jpuSyG61+qHIf6Ufh3abObfDscUdeez4lHEQhEs7ZDyupvz6i4mhK33 UhcOPQhGBo73eqX643k5j61qyPGa3eG+hP79VwcEjDHtYYkJ2Sy8jArdWDjZr+YOXN+w ziSmZchc2jkSW/gSgme+O9eY0GJFuuJmaAZfSz06j9U5eNU9HyNmE5Hsy3pul/ytcZmx vO7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=55Yoxcq3+d/tHhqKEtTkuDqeutda58+RH9+uCLxHdaU=; b=y61cAn0SEOETI2/sNcyXpIUWncHP35WP7p1FfWzW8z7g1J7/DxGXCIloppqzler/V3 X2yUMRO7v0Q7uipWCeAbqRuWtPtGCX/jqFgTRoXnYNg9k0XxjNbkDg82dABa5udPwI3i rQJSiiIRG8StYAeIm5VYUd4q9t5R1bcImTXF25NxmyNlB53TbQBLJVuV46EtkQk6T0TX ka/iVZQDhMskvif+3Ho5NDPjXJO89mKp2474kdY8yVueph82q5uTO9R1DpExIKGdclTj kYbbjvdARFDhTM2slqWn/HzxF+V6vqusJxf82O95BLX7XLGze19aGVIGrQebefxrodcT 94FQ== X-Gm-Message-State: ANoB5pkR4VoAZSQ+wPtnR07KGOfqFnyRqNUWQ5vmkCeYiivTwWR07Vjw hft5Nw4z6xsRGv8oKM85gmoh8tsqMdTvyw== X-Received: by 2002:adf:ab1d:0:b0:242:e73:f642 with SMTP id q29-20020adfab1d000000b002420e73f642mr4712465wrc.184.1669621823018; Sun, 27 Nov 2022 23:50:23 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id n2-20020a5d4002000000b00241727795c4sm11804792wrp.63.2022.11.27.23.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 23:50:22 -0800 (PST) Date: Mon, 28 Nov 2022 10:50:19 +0300 From: Dan Carpenter To: Deepak R Varma Cc: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, gustavoars@kernel.org Subject: Re: [PATCH] staging: wlan-ng: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper 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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 Mon, Nov 28, 2022 at 01:15:43PM +0530, Deepak R Varma wrote: > On Sat, Nov 19, 2022 at 08:08:15PM +0530, Deepak R Varma wrote: > > On Thu, Nov 17, 2022 at 07:03:21PM +0100, Greg Kroah-Hartman wrote: > > > On Thu, Nov 17, 2022 at 06:50:55PM +0530, Deepak R Varma wrote: > > > > On Thu, Nov 17, 2022 at 01:54:49PM +0100, Greg Kroah-Hartman wrote: > > > > > On Thu, Nov 17, 2022 at 03:48:45PM +0530, Deepak R Varma wrote: > > > > > > > > > > > > struct hfa384x_pdr_refdac_measurements { > > > > > > - u16 value[0]; > > > > > > + DECLARE_FLEX_ARRAY(u16, value); > > > > > > } __packed; > > > > > > > > > > Why? This structure is never used anywhere, right? So why is this > > > > > needed to be changed and not just removed entirely? Same for the other > > > > > structures in this patch. > > > > > > > > Hello Greg, > > > > I am unable to confirm that these structures are truly not needed in the absence > > > > if a real device based testing. I could only validate that using the compile > > > > build and driver loading. > > > > > > Think this through, if no one is actually using this structure, and it > > > is of 0 size, then do you think it is being used? > > > > Hello Greg, > > I did not find any memory allocation for these zero length array structures. > > Also, the union or its enclosing structure do not appear to access the members. > > Hence I am leaning towards concluding that these zero length array structures do > > not appear to be necessary. > > > > There are a few other structures that are part of the same union, however, they > > too do not appear to be used for accessing the memory assigned to the union [or > > its enclosing structure]. I think most of the members of these unions can be > > replaced by one max size structure of this union [e.g. struct > > hfa384x_pdr_mkk_measurements]. > > > > Could you please comment if I am reading the code right? > > > > For your quick reference, the zero length structure declaration are online 963 > > whereas the union is on line number 1080 of the file drivers/staging/wlan-ng/hfa384x.h > > Hello Greg, > can you please suggest how should I approach this clean-up/correction? > Like this: diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 0611e37df6ac..6a3df58c9e9c 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -959,10 +959,6 @@ struct hfa384x_pdr_nicid { u16 minor; } __packed; -struct hfa384x_pdr_refdac_measurements { - u16 value[0]; -} __packed; - struct hfa384x_pdr_vgdac_measurements { u16 value[0]; } __packed; @@ -1077,7 +1073,6 @@ struct hfa384x_pdrec { struct hfa384x_pdr_mfisuprange mfisuprange; struct hfa384x_pdr_cfisuprange cfisuprange; struct hfa384x_pdr_nicid nicid; - struct hfa384x_pdr_refdac_measurements refdac_measurements; struct hfa384x_pdr_vgdac_measurements vgdac_measurements; struct hfa384x_pdr_level_comp_measurements level_compc_measurements; struct hfa384x_pdr_mac_address mac_address;