From patchwork Wed Feb 13 21:57:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1041621 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 440D2V66NCz9sMr for ; Thu, 14 Feb 2019 08:59:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 82670C220CC; Wed, 13 Feb 2019 21:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4907FC220EB; Wed, 13 Feb 2019 21:59:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 473C7C220DC; Wed, 13 Feb 2019 21:57:33 +0000 (UTC) Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lists.denx.de (Postfix) with ESMTPS id B271FC220B9 for ; Wed, 13 Feb 2019 21:57:32 +0000 (UTC) Received: from localhost (lfbn-tou-1-411-96.w86-206.abo.wanadoo.fr [86.206.237.96]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 674EF240003; Wed, 13 Feb 2019 21:57:30 +0000 (UTC) From: Thomas Petazzoni To: Philipp Tomsich , u-boot@lists.denx.de Date: Wed, 13 Feb 2019 22:57:28 +0100 Message-Id: <20190213215728.21603-1-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Thomas Petazzoni Subject: [U-Boot] [PATCH] lib/crc16: use non-C99 loop style X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Commit 51c2345bd24837f9f67f16268da6dc71573f1325 ("Roll CRC16-CCITT into the hash infrastructure") has modified the crc16 code by adding a C99-style loop where the loop iterator is declared inside the for() statement. This breaks the build with old compiler such as gcc 4.7, that do not default to C99: ./tools/../lib/crc16.c: In function 'crc16_ccitt': ./tools/../lib/crc16.c:70:2: error: 'for' loop initial declarations are only allowed in C99 mode ./tools/../lib/crc16.c:70:2: note: use option -std=c99 or -std=gnu99 to compile your code Switching to the regular coding style used in the rest of U-Boot allows to fix this build issue. Signed-off-by: Thomas Petazzoni --- lib/crc16.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/crc16.c b/lib/crc16.c index f46ba727c9..89d2cff131 100644 --- a/lib/crc16.c +++ b/lib/crc16.c @@ -67,7 +67,9 @@ static const uint16_t crc16_tab[] = { uint16_t crc16_ccitt(uint16_t cksum, const unsigned char *buf, int len) { - for (int i = 0; i < len; i++) + int i; + + for (i = 0; i < len; i++) cksum = crc16_tab[((cksum>>8) ^ *buf++) & 0xff] ^ (cksum << 8); return cksum;