Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6642954ybv; Wed, 12 Feb 2020 16:39:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxo0MvWJvYUONtpDiSXBdX8vISGA5xCIwmhDCmz967QOMivVDBPIJfPe5Ovbyjwn5Q/UpGB X-Received: by 2002:a9d:664a:: with SMTP id q10mr10803870otm.298.1581554395881; Wed, 12 Feb 2020 16:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581554395; cv=none; d=google.com; s=arc-20160816; b=sCeeGBQrqMzuVJhA7Xtuvomcb3o3dt+/0CpuqB4777R/ptmQ6AQMSvLcgQNyo/I8lt tLFh4ii4L7RnV5aQkcQuQFHS4FLErbgV7HVxVVvwTw+yk36oNIlXYqLU7YfvGgvhmh9W MMEVhPK/Z+WqjAx138VI49iaeeo1HSSoi7mUCbYRZ0M5gjNfbgKlIci8FKsJAUSREHKO Y5wOOoVYqGD5qB18qzxl8PzKPsJSFutWiIbZiQ31J/ybPr02qsvppL7DdYq79ZwYqv7M Ww/TUw+Qb+3tSMUl3cl3GsizZf8rszs/DDLi12tefneIL3rSmidVmtBl9IJrhk5SfGAR N6JA== 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=W5rxnkEmmddJcYu6W8YmSeFeCtiHRsFrV/J1RxPSojs=; b=iMGGa0QdAAeFjVHZF0FWQ3UQuHGaSbX0KGKWgpeRzCtDztxbfuizpyPSdsXXf1SuPk fHtwnYTwhaUepWEXl1jQ0pluiCC0fd6o8cZ46DwJshPxCHmpVvaqjcsOei22l7Rp0wAX hBDoGuYoNc9hIMY6hL6Z4gse+NZEWHfaQzWkEJ/TBaciLs3Rtxi6qmEiOtsHoiukMp+a IvH5EjCw1+vKp6qYLDrinZQMuTHiuqCKAXviGGUI6QKTHYSgdRJn7hd+7ffgBQWzhPnG nqH6VVmzj89fwSz5VVTI+2ZyrVMfQ5cJ8CDC/0z9Z8ssr3LGFn2bc7lGvkERpc6YjnWA UTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Q3oAKG3k; 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 h64si338059oif.215.2020.02.12.16.39.43; Wed, 12 Feb 2020 16:39:55 -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=Q3oAKG3k; 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 S1729397AbgBMAja (ORCPT + 99 others); Wed, 12 Feb 2020 19:39:30 -0500 Received: from gateway36.websitewelcome.com ([192.185.197.22]:20925 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729284AbgBMAja (ORCPT ); Wed, 12 Feb 2020 19:39:30 -0500 X-Greylist: delayed 805 seconds by postgrey-1.27 at vger.kernel.org; Wed, 12 Feb 2020 19:39:29 EST Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 4A1B140138AB8 for ; Wed, 12 Feb 2020 17:53:33 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 22XRjc3fOEfyq22XRjlhtB; Wed, 12 Feb 2020 18:39:29 -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=W5rxnkEmmddJcYu6W8YmSeFeCtiHRsFrV/J1RxPSojs=; b=Q3oAKG3kSVV5k7Ll+WJyZb40ih CqEn/zx1JFKH21BqqxP22Pr1YedrmUtE9CKqG48oW4x/eBtU/Pma3B5ZBuX4vAKJWChR+/P4aEauB ffnfMlPSGE8MUDHieJH4WRaXtD9Nqz6cMmrd4+R4kLZvjcQUlpJv7fW4qNGjlN9aQwuHiW9/sE6Rj YGxi26ZL2SZ+V2OYSAyCXFwYF7x39OXg+b6wATsZUNZQTYQ0PZcRsacYjDkx99lQc0/cXFvlLTCEu MPYjU3AgMLJzvPfCXkjZBb/wXA+Sv5/CsMHLn2v0Stae4FpxlqkgY+dFWEc8wHlHzqq81Ev/uvjp9 +sGAux+A==; Received: from [200.68.141.42] (port=17499 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.92) (envelope-from ) id 1j22XP-003gqx-DZ; Wed, 12 Feb 2020 18:39:27 -0600 Date: Wed, 12 Feb 2020 18:39:25 -0600 From: "Gustavo A. R. Silva" To: Vinod Koul , Dan Williams Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] dmaengine: ti: omap-dma: Replace zero-length array with flexible-array member Message-ID: <20200213003925.GA6906@embeddedor.com> 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.141.42 X-Source-L: No X-Exim-ID: 1j22XP-003gqx-DZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [200.68.141.42]:17499 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 55 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/ti/omap-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c index a014ab96e673..918301e17552 100644 --- a/drivers/dma/ti/omap-dma.c +++ b/drivers/dma/ti/omap-dma.c @@ -124,7 +124,7 @@ struct omap_desc { uint32_t csdp; /* CSDP value */ unsigned sglen; - struct omap_sg sg[0]; + struct omap_sg sg[]; }; enum { -- 2.23.0