Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5333108ybv; Tue, 11 Feb 2020 13:42:36 -0800 (PST) X-Google-Smtp-Source: APXvYqycD2P6N7tkuHBSkXfSqsyQm9yp06kb7WvCs3LlCm0Pq2ZCsWAIzUH/ajsO98t7Ui1sY9zG X-Received: by 2002:aca:5f87:: with SMTP id t129mr4309677oib.36.1581457356101; Tue, 11 Feb 2020 13:42:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581457356; cv=none; d=google.com; s=arc-20160816; b=E34M/3SP3YGkzkI6mOWlAnj0J/r3zTVeUzSLyLMuiCtxvuU4mzpHMn8ObcU4r3UQdU CYOUz8M8XjcynPQf3JaDW3IvNe+b/ug974cm2Llf0IpTEW19yCsX8RjkCpkyc/cyWZP0 YZm7wYd4N2SMSnmyNmYDPNNiblgeJzdnu63hs5VkmwQJGvOJyrY/02HRZyI9zXgtAODz DydzMeqK0DgUilhT82dd9XI1lf89gnZZIReFzjxvR/UR3siEBIOQcCPtB9u/pXigVrKl qyDkPoFjrD/oow/4KlZ4hTkBk9kf3k+XEzKv8HUHGbhitavkoHSC2jTRphxKw+ESNA/M XFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=0/N7mjdKi9+R4kLcU/SMx8qgiSYzHOVxoh2RqMly75s=; b=PrhenSOVd28sdKE5DhqUhVlREv4SiE+KH9XUHylTDUe1zWBy8VcNymIQof/43Il2uN JWvhPoAnvDhpimym/qTsGUiBymg/ceUgUxgH+kgVz3af0X0eGBFk/w9rmbprBIGWP1dA JXUkHtELQnEtUREhHIBrt8WwccXXiMNtGS0CS2oi4YKlrmlVPxaWpyJLke+d3mluqZ1L CQJCEqPlJ7WqEtAZPrR7DvRZpFnCBNyySFKOHuG+brmko3+NKAdB/e0eAOspfHG7wsgz 3fPzxB5lff5nNKVrM6iPP6tYD4CU2tBA/NuqhOBpGzNDfYx1ggD8Jjny9X4sTuZXPpX0 G5cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=l7x6RPEy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s143si2236315oih.251.2020.02.11.13.42.24; Tue, 11 Feb 2020 13:42:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=l7x6RPEy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729634AbgBKVFu (ORCPT + 99 others); Tue, 11 Feb 2020 16:05:50 -0500 Received: from gateway32.websitewelcome.com ([192.185.145.18]:49587 "EHLO gateway32.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729031AbgBKVFt (ORCPT ); Tue, 11 Feb 2020 16:05:49 -0500 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway32.websitewelcome.com (Postfix) with ESMTP id E8EB811A1AA for ; Tue, 11 Feb 2020 15:05:48 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 1cj6jHsAZvBMd1cj6jbTsw; Tue, 11 Feb 2020 15:05:48 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Type:MIME-Version:Message-ID:Subject: Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0/N7mjdKi9+R4kLcU/SMx8qgiSYzHOVxoh2RqMly75s=; b=l7x6RPEyjpONSlZYpjiakJQvc6 Mi+OP2QYKKI7djRIwgHBGlZHzptDixPY2EEESwk2Bql58vPJQmXeC10SHraA0SrO0aju5i5sc2tC3 LuLw3sVQMpqYTAIGftANtXkoJQfyN13VEbdbZ8KJYlPRth3Sb/l8wleorcQz2Bz01G+nmmWv+YyK6 ppu2OlDpwvOMZsHQrLDHL8mZGPqACiIeVKcBGqtQBhGVNGp18vDg2USf5hj5b3Yw8oxtMGY6V8eZT XF2ha5sQy+Sv9gqc3zqhXko1ST+CklRpWehTtCTqrq4RYy1yHn/3k/y4e3SfAnWmNBVYk6uZj/TOt xaBLMHcg==; Received: from [200.68.140.36] (port=31691 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1j1cj5-0028BD-CP; Tue, 11 Feb 2020 15:05:47 -0600 Date: Tue, 11 Feb 2020 15:08:22 -0600 From: "Gustavo A. R. Silva" To: Tomas Winkler , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] mei: bus: replace zero-length array with flexible-array member Message-ID: <20200211210822.GA31368@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 200.68.140.36 X-Source-L: No X-Exim-ID: 1j1cj5-0028BD-CP X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [200.68.140.36]:31691 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 15 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 inadvertenly introduced[3] to the codebase from now on. 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/misc/mei/bus-fixup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 5fcac02233af..aa3648d59a8a 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -107,7 +107,7 @@ struct mkhi_rule_id { struct mkhi_fwcaps { struct mkhi_rule_id id; u8 len; - u8 data[0]; + u8 data[]; } __packed; struct mkhi_fw_ver_block { @@ -135,7 +135,7 @@ struct mkhi_msg_hdr { struct mkhi_msg { struct mkhi_msg_hdr hdr; - u8 data[0]; + u8 data[]; } __packed; #define MKHI_OSVER_BUF_LEN (sizeof(struct mkhi_msg_hdr) + \ -- 2.25.0