Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp700009ybv; Thu, 13 Feb 2020 08:00:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxI5jON+rleRu38OJuZG+HWu6p4//1O6ksQ5rZj5mFYjCwho7qBAiXfMhWnuG5qXxKsPa/l X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr3209980oih.79.1581609630655; Thu, 13 Feb 2020 08:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581609630; cv=none; d=google.com; s=arc-20160816; b=b2ghqUxPPV65+AGYDPcBScS8XiwveKJYyh1H/q+RFfMFa1qrESqPQXncnBFEGrQkSd Bb539mXY86X7mm0MYY8YiF/nrnFVqQHwlVYl12N0IcdhnN2vgVzbwqtzsWCdvhwFNfij 1V32pehKIf+rBBRkSTpX/dA9z40/2TSWjmKalLSh3MbS6wBmJ0n5q8bAVcqA2daDmfGx YqucgL+A0aQEATgStIYsZx5h73MAKggrV+zjuMvGZBZF2cixClT8oHbDAKTgyE84q4y6 0Fn86rMm4uMSl3PeFOpUvcFAUq8NxqNY/EbuoWpGpBPVOO31NsPjN3AJ+5pauu2vbnJi FwAw== 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=NmNOXDdvB98xwhJtElcLMbN7Op+XthJY6SaxnSvAi38=; b=LCx2IDsrlKzorNNrg3yXhgxGUImaWlFlg25ZGtl08KbbqcwD+dg3rfrTFQTNVZRvqj xf75iHqw7NCiNgFkEGu6VOngbuCNmTZL2AuWzKP4KXa52uU/r4bRQEzEYq1tg2vb+eHw N7G244Ygj38/MZ3zVLodbtjA5ARFFfSNv9ErVgjyNB2E0Mgj2OCtVyLpZ6LNRvHrl8t6 4rz9qieN4v/cTb8ne3UAwSmBidOePuUmtDMpSK3vXAp8MPaYYAUzv82RhPQ7d+mRUgw+ 8YAuu0BKL5xHeQeaD6ieMUhfXBzMlLy6p+9fKBp/3VEP3ds9apUH/t3WkzKetrjdKgva hsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=PnRXhWpq; 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 h3si1323638otq.203.2020.02.13.08.00.17; Thu, 13 Feb 2020 08:00:30 -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=PnRXhWpq; 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 S1728995AbgBMQAP (ORCPT + 99 others); Thu, 13 Feb 2020 11:00:15 -0500 Received: from gateway23.websitewelcome.com ([192.185.50.164]:30865 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbgBMQAO (ORCPT ); Thu, 13 Feb 2020 11:00:14 -0500 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 98E413C05 for ; Thu, 13 Feb 2020 10:00:13 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 2GuTjrKXWEfyq2GuTj0o7Q; Thu, 13 Feb 2020 10:00:13 -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=NmNOXDdvB98xwhJtElcLMbN7Op+XthJY6SaxnSvAi38=; b=PnRXhWpqpuP8CcDGMmZsl0bGNa XNQeXo/bLuVdGGn4oHhKjZ9V0qYKbURZQOxyu3tATX/9f3uZtKCoaIear7lD8f3b878q41oKtoxFF pjjXp43uLxs2n0ozqN6aKMwUQqNoA6zbcLBN4goSeehiUYUcA+leArBf0o2T2uZw8z3l8cBBQoBcg FMRdHiQJuYRSpPmqFacjUuE+fgBWN9EfKmeNBrEA2IhqK0IvLV7pg3iVxuh5xg5+8G+fAieB2cPjz t257qJDh4l+u8iYkqWn7TkKXwjyGUN8294Sa92MAGjcbc5Y7SlTyvZxGuc9N+37uwhuXKSBlXEUby LgImiwtw==; Received: from [200.68.140.15] (port=13875 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1j2GuS-003Y1i-2Q; Thu, 13 Feb 2020 10:00:12 -0600 Date: Thu, 13 Feb 2020 10:02:44 -0600 From: "Gustavo A. R. Silva" To: Mark Fasheh , Joel Becker , Joseph Qi Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] ocfs2: Replace zero-length array with flexible-array member Message-ID: <20200213160244.GA6088@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.15 X-Source-L: No X-Exim-ID: 1j2GuS-003Y1i-2Q X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [200.68.140.15]:13875 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 5 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 --- fs/ocfs2/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 68ba354cf361..b425f0b01dce 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -91,7 +91,7 @@ enum ocfs2_replay_state { struct ocfs2_replay_map { unsigned int rm_slots; enum ocfs2_replay_state rm_state; - unsigned char rm_replay_slots[0]; + unsigned char rm_replay_slots[]; }; static void ocfs2_replay_map_set_state(struct ocfs2_super *osb, int state) -- 2.25.0