Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14426387rwb; Mon, 28 Nov 2022 00:19:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5fr/ExNy1LoCOFLkcdwHkQBxKA97mL4QS2e2Mnu/Ruz9SOo2HrOx7es7KatqmpEnjXsjhc X-Received: by 2002:a17:90b:4cc8:b0:212:f2b7:2282 with SMTP id nd8-20020a17090b4cc800b00212f2b72282mr54545640pjb.48.1669623543310; Mon, 28 Nov 2022 00:19:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669623543; cv=none; d=google.com; s=arc-20160816; b=F/VhAJDlfnty4KFJg2bkB0gN2gyQbPF6SxQu8PZl4fkCw7bdDwjN/3o1KZg5I44h+y 7W6FvFOHhtL7GFtpbo/ySCq59KMeI9oOfnShRLMuvfndLa54kDpH3aAqnJDANAPZJq5Q Fne9TE6OPhnfqnGauCGChdMSK0/ehLuvdJXM62YoX5GZB43S3C63xzYOVHZkY7SgvULA x/Dr2j54F9mSPF0HuPY5puAYOyLTbqHEpNNJwx6NUojnlsX6QkR/7WDKOIa9kVCiYrhu LAUwFTYq97RVeU5YZb5PY2/ukfTVW1vw4YXj+3Tc6xuCtDqCde+xXELvdXWsBwkGKHOF opLg== 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=5drOeM2LfoTsfGYssP2O+mG+LdGt06yy4OkPkLDVEDY=; b=oxqteLA0dGXPWtIfowsmokErW4628uHCgV6AWFJP096VRHJxlUSytiNN85BGPvrcSb /BIi1vTURgcNNnOnT+DehXwcD4538LmLtEgV9dszedrB/17uZrm6OPsvdwHPaU9ss9Sn l350Wuvbg/RcmWdDFwuxoUtL6pcxdI2lI/AWIQkYejpxvIsZN4/vjG3lPHcR+k/nJPyB Gi4LN5dV4OlhugqSQUUqv4WmWBgRU45B5FYonSvq2wCAkb96NVMwH5L3NVkXW+UVX2h0 mcG357ae42DHmOxQ50VWk2AC4Lsj3tntL9vjHTbmsjxSxA2ZTetey4Zdu0ps39RRhUg1 3yUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=OUNY7pg5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a63e415000000b0046eecbac47esi11429629pgi.28.2022.11.28.00.18.52; Mon, 28 Nov 2022 00:19:03 -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=fail header.i=@mailo.com header.s=mailo header.b=OUNY7pg5; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbiK1HqK (ORCPT + 83 others); Mon, 28 Nov 2022 02:46:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiK1HqJ (ORCPT ); Mon, 28 Nov 2022 02:46:09 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84DC012AFB for ; Sun, 27 Nov 2022 23:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1669621549; bh=wYZlN96pJuQ8Qrp+PoOImcb4RGZJwH09T2Ok2nM5puc=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=OUNY7pg5SGi7uFe/7Nok53OSdDhJgUysatqxNvXXb9IfBI6PeRB4Z8B8V19SC2GdD /6/5N7g4Hd9XxJJV3GO8wfm52gxBcX1mQJOQOcT3mdbNkGucdVr55Ra866R+EobSLw CEMs8xS5OWel5m91NIjCbSRipwnbtD6kTsxnVrOU= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 28 Nov 2022 08:45:48 +0100 (CET) X-EA-Auth: j8P34HFCLhZ7GZTTP7tVWbf4kJ0AtgmdBJOgHoKNeFxhwTeYFL+kIesUS7aPIzfcBoicB+Lc7fOxN+J1zvXsBm7I3VCnj8UU Date: Mon, 28 Nov 2022 13:15:43 +0530 From: Deepak R Varma To: Greg Kroah-Hartman Cc: 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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? Thank you, ./drv > > > Thank you, > ./drv > > > > > > > This change that I am proposing in the interim would enable the compiler to > > > protect the structure from addition of a new member below the zero length array. > > > > Why would you want to add a new member below this? That's not what is > > happening here at all. > > I came across this one old commit where such an accident happened. This is from > a recent LWN article: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e48f129c2f20 > > I understand the C99 now protects from such an attempt at the compile time > itself. > > Thank you, > ./drv > > > > > > Please think this through a bit more. > > > > good luck! > > > > greg k-h > >