Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5558738ybf; Thu, 5 Mar 2020 02:54:50 -0800 (PST) X-Google-Smtp-Source: ADFU+vuNeRN3R01ilWSIaUlPLnGnw3FIdn9dbimeMvVNJeEv4edC5eQvTRcdnaGkL+P9DrTCcUjV X-Received: by 2002:a05:6830:1112:: with SMTP id w18mr6342697otq.185.1583405690319; Thu, 05 Mar 2020 02:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583405690; cv=none; d=google.com; s=arc-20160816; b=CebZmp/SlOfr3Qx7v07+ID69axWrbmC/Wb7D+5dt1EvoSFj5EG1CcSrONjP5kI4Xu0 FepgXX6Dm8+fl72xcRz9J0Bkf+8Qcg2X1V9hHiVSxmKDyn+IIYLwsByHVTa4u8WexBOz c0rpKFpws5NRGmuoh5/T3H7eg88HXF/ygzFDja6AP/n2DCiOAmxnDUhrt0amMthiZBDd pelnKbQiLRTH9IvHMy68tqkX8DlFCePEAbhKfftcDe3hKJTtzFJcShFd/WCQfXoPdw4C 9mmTwndpsM/DaKdhq4nyouAkKYWbDsKobwFg7qHMsqSILrRPCqn6Vc5k+3+djIfKIgZ2 Znfw== 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=LuRs1qAlN28B29OQw5z0bMAZXPOpHkdEvS1HCweV2to=; b=J5sq0g90ph6eKjy//50A2xuBX3QD/L8aDmhylQBGNbSOCa1PSSnzUmnGuq2bFr9ogA uA9JVIi8JV+0yP1IClqSTsR6nyTkKvJGuaxQNSz1LhYBe7CMzKp1RcAOk8sOTHabJ4kP /PrE4XSR2lqElP+kg6gLhBncUIUJ83cxU0DA+Uy07kqyWmDryCPNhCbfCNe20KfyOEPO 89eub+IeNuAVbIZCcQ1RhIn+dJSTyQliWZpu49mYeiSGM+UI/fBK3MTb+NbT00XFcWOb +cwHwUfXOKzQ7df3layvdTdsoEWXhrgY0gC8+VAbVpOvKcjdHEUEwEBhS/oYj1O6FAKm VaAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=P2G2T6Nz; 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 v203si3389248oif.224.2020.03.05.02.54.38; Thu, 05 Mar 2020 02:54:50 -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=P2G2T6Nz; 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 S1727112AbgCEKw4 (ORCPT + 99 others); Thu, 5 Mar 2020 05:52:56 -0500 Received: from gateway21.websitewelcome.com ([192.185.45.38]:41228 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbgCEKw4 (ORCPT ); Thu, 5 Mar 2020 05:52:56 -0500 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway21.websitewelcome.com (Postfix) with ESMTP id BEB86400D1853 for ; Thu, 5 Mar 2020 04:52:54 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 9o7ajoJasRP4z9o7ajBf3e; Thu, 05 Mar 2020 04:52:54 -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=LuRs1qAlN28B29OQw5z0bMAZXPOpHkdEvS1HCweV2to=; b=P2G2T6Nzogd7c5f62gOUBj3otz vnZ/XZXVqydv1D+9sguTfoO7g4TG/0430MghYJHQ4Sa7/losGi7z3zC/IN/7bfP000+KPmZeVQkrL Qmn+4HZVMsC5P8Z+X1GY27CKJsx+K5nQ0/PlwSulBzweYfB+HB5rrz47PY2iFoC+OnGfp/RdN89IH ib+D8p7kQIU3lcFF7/uZo+7Jfjw3pbEnYQehdOwKj/EfF7rcm13vpvDdRo/q1o1SuHAbLcGRbFmwC baCztrg/2y+Tj7/JwxRRI6fxs3h5+dpT8nTwcTlPU8HpTt7ygi3DD/4yTa5M1JCote0msP+AMptwv 2d5zvtow==; Received: from [201.166.169.220] (port=30355 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1j9o7Y-003fkB-5w; Thu, 05 Mar 2020 04:52:52 -0600 Date: Thu, 5 Mar 2020 04:55:58 -0600 From: "Gustavo A. R. Silva" To: Hans de Goede , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] drm/vboxvideo/vboxvideo.h: Replace zero-length array with flexible-array member Message-ID: <20200305105558.GA19124@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: 201.166.169.220 X-Source-L: No X-Exim-ID: 1j9o7Y-003fkB-5w X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [201.166.169.220]:30355 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 26 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 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] 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/gpu/drm/vboxvideo/vboxvideo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vboxvideo/vboxvideo.h b/drivers/gpu/drm/vboxvideo/vboxvideo.h index 0592004f71aa..a5de40fe1a76 100644 --- a/drivers/gpu/drm/vboxvideo/vboxvideo.h +++ b/drivers/gpu/drm/vboxvideo/vboxvideo.h @@ -138,7 +138,7 @@ struct vbva_buffer { u32 data_len; /* variable size for the rest of the vbva_buffer area in VRAM. */ - u8 data[0]; + u8 data[]; } __packed; #define VBVA_MAX_RECORD_SIZE (128 * 1024 * 1024) -- 2.25.0