Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1979306ybv; Fri, 14 Feb 2020 09:13:28 -0800 (PST) X-Google-Smtp-Source: APXvYqw7u1MnbE4SbycVH07OK+/c8rDOEBFXRg3vyeEG/nsfSvgKQieUkCVjoJSTb1cJtZ+zJ775 X-Received: by 2002:aca:2109:: with SMTP id 9mr2425242oiz.119.1581700408011; Fri, 14 Feb 2020 09:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581700408; cv=none; d=google.com; s=arc-20160816; b=yeKWkhyLOnhfInnccv2pUqSfWy4ic6rwwc3/IhsRXxqTkmTIJmO75/93vJe/jFoEJp q2s6YslY1+AqJCPypJciqZfpd5h25y9+OHu50RD7a9FfXM/9MOOhnYVr/98EFDRhEccb FqIwNJePHkCvIItoK98ZTEWhiLr1mWuYghJo+D0lzSYM0tqtnY0So5agZXi/DV8nOL0O GuCr/2khHZxzFqJ5ZLmElTifpDEWmouZIlhGlxMudzT3FEkSJxEIlFKeoXJmqJnz4ASV CYRdkIsLXM0g6TscEjF9RvTL15uq7oFlS7ASCJMMc1lVGpyRSIxTps6CPhaoc/5GSzL6 z1Iw== 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=vO5BqaYniwiYoqFLBJR/Sz5SU1jsfy+FC64E6Sg1eEo=; b=shNQcDwqZId+1kwPRqRjgwxXKhaRaLDsKIPwFhVOe0OkIQa0w5RGvsxnC+Oly2HLr+ 6ppfs7ap9D/AlZqRDGFyuDhD+tAKXN/GHCuKosAS9kXcriyuJcfR4AtDrtZ4O5WeegN+ nAG0AB8NvK+doSX1D3RSgBYONWJJKvk4Z0RgyOD6vBJG3XaqukzetYTSOYCifypuYHNh MaP6+fvWmJenSXkA6Bp6XoB9DOw51f/2wOwZaxzbkaIAg7XMfRxjtnw9xp1nlCJUhbBe SyYZiwJf1yPJqFrmjj3mveNe/aZc/TxywXVE740aVDPWJBme+DuFBwQ6if7eqfqQ0Ayj qwQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=xFFbJA+I; 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 i15si2914236oik.46.2020.02.14.09.13.15; Fri, 14 Feb 2020 09:13:27 -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=xFFbJA+I; 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 S2404115AbgBNRND (ORCPT + 99 others); Fri, 14 Feb 2020 12:13:03 -0500 Received: from gateway23.websitewelcome.com ([192.185.50.129]:25417 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403963AbgBNRNC (ORCPT ); Fri, 14 Feb 2020 12:13:02 -0500 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 8868D42EC0 for ; Fri, 14 Feb 2020 11:13:00 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 2eWSjsoajAGTX2eWSj4cyy; Fri, 14 Feb 2020 11:13:00 -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=vO5BqaYniwiYoqFLBJR/Sz5SU1jsfy+FC64E6Sg1eEo=; b=xFFbJA+IerxhKq+1vt2ym1/nT7 A20pZYINVOsDj42M1t7D5kS3HrtCqDEMBuOZmh69huYuCC9QBlejTkYhzrZK/p3nSICjU4Gwky0k+ NMCOOE+bFB+3SeMQf3tfg6YNRHNAeHc9bx5JSaPHQXzy5NmWAD+LCPn3Rs/zKR5wXlef2T2/IbO4d vj6wwl4A3Z4ZgDlT6kPje8tlmChLTtO69rl23WDIy3ujJDacXHSshTGkerU6K29gDhSV5a76xvsFK YVGNq/rmOLaZeUrUOfqg4BeiBVaMkrzVGnoblh3ZkCslye+sBGA1aEbncU7GrPBiqdxjjccqY5fBJ 0QldctbA==; Received: from [200.68.140.137] (port=17205 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1j2eWQ-003f5s-Kz; Fri, 14 Feb 2020 11:12:58 -0600 Date: Fri, 14 Feb 2020 11:15:36 -0600 From: "Gustavo A. R. Silva" To: Vinod Koul , Dan Williams , Orson Zhai , Baolin Wang , Chunyan Zhang Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] dmaengine: sprd: Replace zero-length array with flexible-array member Message-ID: <20200214171536.GA24077@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.137 X-Source-L: No X-Exim-ID: 1j2eWQ-003f5s-Kz X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [200.68.140.137]:17205 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 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/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 9a31a315dbef..954eff32cc05 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -212,7 +212,7 @@ struct sprd_dma_dev { struct clk *ashb_clk; int irq; u32 total_chns; - struct sprd_dma_chn channels[0]; + struct sprd_dma_chn channels[]; }; static void sprd_dma_free_desc(struct virt_dma_desc *vd); -- 2.25.0