Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2077334ybk; Mon, 11 May 2020 11:21:22 -0700 (PDT) X-Google-Smtp-Source: APiQypK46BBOayZu7UqySb4BEOyEu9Pz0aS1ANh5Ad6Nd1r4piucxHUgLHQ+B9aUMcVCnZMluAIE X-Received: by 2002:a50:a365:: with SMTP id 92mr15137512edn.220.1589221282597; Mon, 11 May 2020 11:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589221282; cv=none; d=google.com; s=arc-20160816; b=l8vaXzK7aYxzeLcO+6Vst6YqisWY7ZYLbgE8Czkt5h3t6yEG83IG/2C1ZwzVq7Lr0s z4dnS1Hi7ONr9NIwjyJZQe/ceeKmGmd4x71IrZfTrRc5hbWpy4g+tRI4BXkgYUtqJqGr Cu/I0Yq7K0B2oUi7yJJckUdnhDU6038OAZu2Ayd1GDiOqSXzKyGLPBur2K7yI/ohAIFt cPFhWGMPPxg8UYjysUE0ewwNtsDtjgJEYoLmjrYX5pdF6Cq7gBWc9mS/kacWKIgduah3 zHYklIfbG+lACXiajuY8yKMXKEsl22nsg/Zd6dXyhG+SMGIjSsOMzu3qa2Qvn5r9Dv6i +laA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=lbDC7MGahZRBBNgxw3hJed5G3ga/oqMp4WYo61050YQ=; b=T+POEyno0Ihj3YfqypK2lNJFkYZtJCEKRlugkEeya1lIhPfS/Wm50wy1FLZom8Nq5w BprS4/RttxbvXE1+eEmQwphOWWo7N9Su2kBmtuzMsKiqE8NzIsm9CEPZrAshBowTK9dx a5l4/XYgvQwbUCMWiCHxcbYRWG0Fq85AndMByJIdGVgJ5hBgUb0DGxkqqjpyA0seEC5J CFDC5j655ZV9LjMAqi0awgmMRfnWBl5lC7HlKAC/P7KPJqN0K7+ogFbtu6skYsXT324G MlotiyBQ3f0Kk4P+4XbPhnnspVC3Rg8pB7c3Mn6bt2DInNEAUv9OWcVyDzYOvkLQj3Fa E3BA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si560119ejx.200.2020.05.11.11.20.59; Mon, 11 May 2020 11:21:22 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731028AbgEKSRM (ORCPT + 99 others); Mon, 11 May 2020 14:17:12 -0400 Received: from mga03.intel.com ([134.134.136.65]:53698 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729678AbgEKSRL (ORCPT ); Mon, 11 May 2020 14:17:11 -0400 IronPort-SDR: 9L4snjHpDpN67h0KhUNqufKvZo8GCBVf31NpAAW0RvOXEEXiVHoKkswqHNKCXFnQ9Fs20DuFfM +USTCitSbs/A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2020 11:17:11 -0700 IronPort-SDR: 38zTCriKg5Yq9VmhZtWaXyixpm+lKVTUX16kvRsUQbv+OUmVYmqVh259nwt+H8KjuKpm2g0qk4 x3XR6ktGUvag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,380,1583222400"; d="scan'208";a="306251281" Received: from crojewsk-mobl1.ger.corp.intel.com (HELO [10.213.1.152]) ([10.213.1.152]) by FMSMGA003.fm.intel.com with ESMTP; 11 May 2020 11:17:09 -0700 Subject: Re: [PATCH RESEND] ASoC: Intel: Skylake: Replace zero-length array with flexible-array To: "Gustavo A. R. Silva" Cc: Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org References: <20200511174647.GA17318@embeddedor> From: Cezary Rojewski Message-ID: Date: Mon, 11 May 2020 20:17:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200511174647.GA17318@embeddedor> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-11 7:46 PM, 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 > --- > sound/soc/intel/atom/sst-atom-controls.h | 2 +- > sound/soc/intel/skylake/skl-i2s.h | 2 +- > sound/soc/intel/skylake/skl-topology.h | 4 ++-- > sound/soc/intel/skylake/skl.h | 2 +- > 4 files changed, 5 insertions(+), 5 deletions(-) > Acked-by: Cezary Rojewski Thanks, Czarek