Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2467060rwb; Thu, 17 Nov 2022 11:08:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6LYlFb17Rywb/4mAKjSG7ZIQFlkMFHwb73Epi7XekimGP+s6phM8Q9tQTMuGAvwFACEEYn X-Received: by 2002:a05:6402:1caa:b0:467:78ce:5fe6 with SMTP id cz10-20020a0564021caa00b0046778ce5fe6mr3291519edb.325.1668712105751; Thu, 17 Nov 2022 11:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668712105; cv=none; d=google.com; s=arc-20160816; b=nZG+o/8mQx+3wAbB3Mcm8iJ2hdSZfH6TiQM3rmyKlGjR1n/8ef+XNaC4cOcr3eHYU3 VopRpxLRHaVIn5UVgpNlM1BA+syOCsgpeA+ctnSQ0s5/Eo7LA3jJmVt61XbtaBNlhWor P1wpIB+iyb6RywqwgCLZYulj+kGVPGDNEyrbhYzcZ7nhvOM9++YnmllSb/8vkHUoxn+g LTp1sCpwZUCzw0pIERJhaJ1nevipihQjX8TP6I+KGqNFqISYWblBijOxVhG8jerNF/cE zEwt7AUUGcMGyO6YbKqRSeyzKFW+GpDaqBvrqQ7/y7FfHDoyX8eHmh1upTGhaE0mluEV N7Rg== 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=rCIs3rq9y39Qdw6I1gHlcgrTG+9sAxqgCR3LjuzcWz4=; b=xbrw3P98tA7kGFjjZ3peT+6otro68PzHmm9sdQxsg9TwXoE4HUqH6YaHmgwhwfSOHC MvjQcf+SREYyZnjdpVh3FRrHkUkswLb2sb78mtjXZF2fvA5jYerhkNhab7h2wswndY+n VeUE/1/cP/xdcY7Z6zecYND1E2Q3jSDKyMbTg1Qq1s7KVyRtZMqLtSjnq8w/vK3vlR/s 2fvsn8ch5Eng/IqtNacThlbOtbX4Bn4NTUrkbKE6LTA10qMDYh/NMzU3jomTj+1MwudC sL5xvMn/jJbSJyo30oz/En8jrvcegmK71eeYapr/KHBmyaV9g+6iQcOkUsHxJxyU1vOI 3A4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VZEIAlFP; 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 tl2-20020a170907c30200b00781599eb7dbsi1047691ejc.573.2022.11.17.11.07.31; Thu, 17 Nov 2022 11:08:25 -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=VZEIAlFP; 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 S234602AbiKQSNu (ORCPT + 93 others); Thu, 17 Nov 2022 13:13:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240421AbiKQSN1 (ORCPT ); Thu, 17 Nov 2022 13:13:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35CD587576 for ; Thu, 17 Nov 2022 10:12:59 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CE9E9621F4 for ; Thu, 17 Nov 2022 18:12:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DB60C433D6; Thu, 17 Nov 2022 18:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1668708778; bh=KCxIvC+hdiZE+1xFJ8BT4IQmgI+9o6zwKKamoBYbuNM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VZEIAlFP2o9Yg1Z/w7VpifR6D0Fwaxj/sMh8ldKE1jsH9NbJwe2MwIfRjTAHJeJjE 9KAfvkOaR9UmvUrI/KUoZ5IXk3Cdjiwuw99hwL7kwsjS22tKw08hw/ST2ptF2Iio+z Ta/6iFmu/XE88+Udz+7LzikWgNIrnawguU5YZQeo= Date: Thu, 17 Nov 2022 19:03:21 +0100 From: Greg Kroah-Hartman To: Deepak R Varma 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=-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 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: > > > The code currently uses C90 standard extension based zero length arrays. > > > The zero length array member also happens to be the only member of the > > > structs. Such zero length array declarations are deprecated and the > > > new C99 standard extension of flexible array declarations are to be > > > used instead. > > > > > > The DECLARE_FLEX_ARRAY() helper allows for a flexible array member as > > > the only member in a structure. Refer to these links [1], [2] for > > > details. > > > > > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > > > [2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work > > > > > > Issue identified using Coccinelle. > > > > > > Signed-off-by: Deepak R Varma > > > --- > > > > > > Notes: > > > 1. Proposed change is compile tested only. > > > 2. Solution feedback from gustavoars@kernel.org > > > > > > > > > drivers/staging/wlan-ng/hfa384x.h | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h > > > index 0611e37df6ac..3a1edcb43e07 100644 > > > --- a/drivers/staging/wlan-ng/hfa384x.h > > > +++ b/drivers/staging/wlan-ng/hfa384x.h > > > @@ -960,15 +960,15 @@ struct hfa384x_pdr_nicid { > > > } __packed; > > > > > > 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? > 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. Please think this through a bit more. good luck! greg k-h