Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3615210ybt; Tue, 23 Jun 2020 06:49:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRASngtkke/Ysjm91N8lHrUPlh9IICSH26mlslKlv5eMNNkR6LkWit2BXxlQAT6muucyhD X-Received: by 2002:a50:cdc6:: with SMTP id h6mr21531294edj.111.1592920161046; Tue, 23 Jun 2020 06:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592920161; cv=none; d=google.com; s=arc-20160816; b=USYqOTdm0BPn02ywB/LQiM6vnblJFXZJ0Yjl3Y/n2/JjXfbjY1f4FTlsLOImFi+1je 3z2XKlTLbhYWULa++9y2Yer3NnfVLR1IWVgPtLyzXx9YktULzGLFyGO6nd2svhbfeP9s lmQdKZd0Spq87ImahxZCUab7MtnWA/kNHdn9B9m29ddEIzOTQAgSCOCH+pgccSKVeNCw wsOL07RixUhJi4fV85hKwQFeI6jKQFlbmeSu5cw/HPZ6nD9HIe0epCiZsDZ/3YnDuPM8 Iv685O2REaLFpoCpkHwObPcTwJFzqrp2FlHO7QYOfo/bdrINRLCZxFl3/WgCaCz7m8Kx K+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yB7mBYOb5pHmRDyADOswCcoM+Wao7KTnBuR1N0wTjcI=; b=FnCuh3tZ1DJC2+fx+a+cANptG/vKqcSkVZnurWsgf+T6O8h6u+HuIqdW0DK2qmxVzW hM87Rz/IBm9SLLdo3fZ3pP15TO8Tm+35gJO9JvaOWR1Ea0kziZijEYUX36Kyd+/7nV0N bfmoiwg3Dmtg5Gn3cG0268Zgc1BIa2549JYgg9ukJFLEpQl6OIMYnxodTMU6w+XZSTZB W6iyplgWvhaqfMoO3UykvhJxBbhJ4dI4wk+Z1zGQLREuN3Mrj5mEb+N0jTtlkzv51G0q waN9S9Z4+RRKbBJpvOF5IM7PUgW3T7w3qaF7Vr4F3j3/lZ9hnBKhp4YfmR6usclbNwJJ dyRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=r3M0SxSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si4947314ejv.451.2020.06.23.06.48.56; Tue, 23 Jun 2020 06:49:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=r3M0SxSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732687AbgFWNrB (ORCPT + 99 others); Tue, 23 Jun 2020 09:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732658AbgFWNrA (ORCPT ); Tue, 23 Jun 2020 09:47:00 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C07C061573 for ; Tue, 23 Jun 2020 06:47:00 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id x62so12025550qtd.3 for ; Tue, 23 Jun 2020 06:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yB7mBYOb5pHmRDyADOswCcoM+Wao7KTnBuR1N0wTjcI=; b=r3M0SxSQyPOiFsM6AdXBkzfLEs0ccEX18X/VK2sm+iGNVloEXppIt21C4F2MZzwn7J Q4y4dfqn36aZt0P5k7RBV8CcmPHacaOttgozh0h8rsivQWB5SBBxlJH/GRjBsQdWgzWm ieswkemih+o7RJ2R9TNfVB1VxiBfGv5kLAHQ1OkXAps/j8pqE2dfBYoUAgw4zm/kH2G+ YajKfaNjM1h8JWGxm43c393ZFVL/MExnBiP2++QrD+tnHKthwzOB6l2MNGwF29PWKtwW fdUVrXiLowep1hUjoykGwAKJ3rAM2Y8OgXlosAq/j/N0vHaAo0V0L17r/8kt9V8H2J36 7ixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=yB7mBYOb5pHmRDyADOswCcoM+Wao7KTnBuR1N0wTjcI=; b=mmR2ydL5SYWdr++cWja7BblUrtLGBQGTDrhb2ewtqbAPf2hBG2kFZK0agYnLwE57um zO8bgpG5I4B9N+WZN5B/pFCBQX00rN1r2WzTfo7p7/dp/QZNoV9h7xzlXL+A5EAnzJ48 POMInPRcNyeG07IStTy/uH9H/ku7yDtHVBlT/AocXIUtPBb5jU+obq3w0k90VeoVkMNN B5c1WC4xgN5RgXc4A2kTRWbJJYziZlO+8M5liRHLzoFj6ArZSCzZ/ox4Q/rABiNDwbNN oWA+Ns8STulxy6lJUl/XspCWTAtUAoZctYPZqc3iYe/XQ3tgJiBKdWM2uDIMEeWr7P4G u0RQ== X-Gm-Message-State: AOAM530Gz136ldnNtIi6eIhmaGq5OmnaL52SJ8Q8Gj2cIBbaYR6rGDBG v7iiuYP2Zb28HZGlfjltswg= X-Received: by 2002:ac8:4d44:: with SMTP id x4mr1288201qtv.34.1592920019691; Tue, 23 Jun 2020 06:46:59 -0700 (PDT) Received: from localhost.localdomain (209-6-208-110.s8556.c3-0.smr-cbr2.sbo-smr.ma.cable.rcncustomer.com. [209.6.208.110]) by smtp.gmail.com with ESMTPSA id o6sm600754qtd.59.2020.06.23.06.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 06:46:58 -0700 (PDT) Date: Tue, 23 Jun 2020 09:46:56 -0400 From: Konrad Rzeszutek Wilk To: "Gustavo A. R. Silva" Cc: Peter Jones , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ibft: Replace zero-length array with flexible-array Message-ID: <20200623134656.GB5499@localhost.localdomain> References: <20200507185544.GA14695@embeddedor> <20200521183235.GA29907@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521183235.GA29907@embeddedor> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 01:32:35PM -0500, Gustavo A. R. Silva wrote: > Hi all, > > Friendly ping: who can take this? It is in the tree. Let me send out a git pull to Linus in a week or two. Thanks! > > Thanks > -- > Gustavo > > On Thu, May 07, 2020 at 01:55:44PM -0500, Gustavo A. R. Silva wrote: > > The current codebase makes use of the zero-length array language > > extension to the C90 standard, but the preferred mechanism to declare > > variable-length types such as these ones is a flexible array member[1][2], > > introduced in C99: > > > > struct foo { > > int stuff; > > struct boo array[]; > > }; > > > > By making use of the mechanism above, we will get a compiler warning > > in case the flexible array does not occur last in the structure, which > > will help us prevent some kind of undefined behavior bugs from being > > inadvertently introduced[3] to the codebase from now on. > > > > Also, notice that, dynamic memory allocations won't be affected by > > this change: > > > > "Flexible array members have incomplete type, and so the sizeof operator > > may not be applied. As a quirk of the original implementation of > > zero-length arrays, sizeof evaluates to zero."[1] > > > > sizeof(flexible-array-member) triggers a warning because flexible array > > members have incomplete type[1]. There are some instances of code in > > which the sizeof operator is being incorrectly/erroneously applied to > > zero-length arrays and the result is zero. Such instances may be hiding > > some bugs. So, this work (flexible-array member conversions) will also > > help to get completely rid of those sorts of issues. > > > > This issue was found with the help of Coccinelle. > > > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > > [2] https://github.com/KSPP/linux/issues/21 > > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > > > Signed-off-by: Gustavo A. R. Silva > > --- > > drivers/firmware/iscsi_ibft.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c > > index 96758b71a8db..7127a04bca19 100644 > > --- a/drivers/firmware/iscsi_ibft.c > > +++ b/drivers/firmware/iscsi_ibft.c > > @@ -104,7 +104,7 @@ struct ibft_control { > > u16 tgt0_off; > > u16 nic1_off; > > u16 tgt1_off; > > - u16 expansion[0]; > > + u16 expansion[]; > > } __attribute__((__packed__)); > > > > struct ibft_initiator { > >