Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2542716ybk; Tue, 12 May 2020 01:58:16 -0700 (PDT) X-Google-Smtp-Source: APiQypLCxOwykZED9et2cXNNJShF3Hc1+l6AlRulG9K9PYoj1vpu8wqY3IeOxqRpZqxnXOqihll3 X-Received: by 2002:a17:906:9484:: with SMTP id t4mr16517853ejx.332.1589273896347; Tue, 12 May 2020 01:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589273896; cv=none; d=google.com; s=arc-20160816; b=fe0sY7avbd+XC43AWtPcalqDW23grYov5iGXkxO7CuQ1YdT7SB4KONLJjCaDeCDqY5 OoJpv1bx4eFrzWJmNApLRC+1Diy5mzGtsG0ijKz7NtvVCiXcYLXOWi4xCu3LQe5dPouN m9pTHI3wR6nR82tDbQ1k4jsdONJ3MEMEeR4v9j8pnPUfTgO7adT3Hb/jHr4qA3AHX9tH vHtXWJFgR2nkb3QXwb2ZKuucKsyUX/tqs51ZDYKNinufhixxjpysnThb77qy3Cz3RKah bcn25wEZc5nvR7Hur6gKkYuyRKoSn7Fb38xTpvfjBWz8mG++r/k7rgqBYTvHBDDne+VH FBrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:user-agent:cc:to :references:in-reply-to:from:subject:content-transfer-encoding :mime-version:dmarc-filter:dkim-signature; bh=TE5Nfuk2oduoFVkWNHpOml0beSjopnpK1dfSsd9gDvI=; b=yIAcepcMmotEWWAxemn7LKyievVPTkak8R1Y65edAap5YLIgcAIi+U+GE4noeQmkHX VVPRZjNVlDXhYPMWy6BlzLF4g4AzWuxYHqH0ajG+jdTTsz9QJ562xTgjke/zpXGul3/6 nANLEXRRZRCFyEwEkjFE4RYWLsKFJxxIfRH3CL5wL2HJ42DFIgPvR2vkTG9uENL9ykJ+ kUQ+U65AHWolbO4dFtOmyCinLgGYZFoNcVU0Ipgs0ZRKXn1cBHpHX+vAgJ2nrgBKKpHd iVgGweZGMhw2tEicUjR4lV3Yv4BBUe4kJ9zE7mNlwDtVt8aYiZ6YA+Jo76hKGTuEFe0C Kk8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=pKYqzLit; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 n8si6750847edq.213.2020.05.12.01.57.52; Tue, 12 May 2020 01:58:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@mg.codeaurora.org header.s=smtp header.b=pKYqzLit; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729240AbgELI46 (ORCPT + 99 others); Tue, 12 May 2020 04:56:58 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:22160 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgELI45 (ORCPT ); Tue, 12 May 2020 04:56:57 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589273817; h=Date: Message-Id: Cc: To: References: In-Reply-To: From: Subject: Content-Transfer-Encoding: MIME-Version: Content-Type: Sender; bh=TE5Nfuk2oduoFVkWNHpOml0beSjopnpK1dfSsd9gDvI=; b=pKYqzLitfAtnF3w5BzRXTj+5nSi0jugks+lzhis1AOVwf2A2JUJO8ioGtQ0ITTLGEwFxAWqq QEhGf1SI7zc/e2Lgky5qQG33HnuhFu67Dh9HY06hDhKEAI9RXEXPj+Vx/3v3LLzp6KV5hJop r1I57nTS9WdX+ZDJXCrkj88+feE= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5eba64d0.7f45f3618618-smtp-out-n04; Tue, 12 May 2020 08:56:48 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 85C80C433F2; Tue, 12 May 2020 08:56:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=2.0 tests=ALL_TRUSTED,MISSING_DATE, MISSING_MID,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id C6A8BC433CB; Tue, 12 May 2020 08:56:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C6A8BC433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] qtnfmac: Replace zero-length array with flexible-array From: Kalle Valo In-Reply-To: <20200507191926.GA15970@embeddedor> References: <20200507191926.GA15970@embeddedor> To: "Gustavo A. R. Silva" Cc: Igor Mitsyanko , Avinash Patil , Sergey Matyukevich , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org User-Agent: pwcli/0.1.0-git (https://github.com/kvalo/pwcli/) Python/3.5.2 Message-Id: <20200512085647.85C80C433F2@smtp.codeaurora.org> Date: Tue, 12 May 2020 08:56:47 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org "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 > Reviewed-by: Sergey Matyukevich Patch applied to wireless-drivers-next.git, thanks. 55bb8a2b01a3 qtnfmac: Replace zero-length array with flexible-array -- https://patchwork.kernel.org/patch/11534767/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches