From patchwork Tue Mar 5 05:48:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10839047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8ABA14DE for ; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D74AB2BB98 for ; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53DB2BCA5; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D8C52BC80 for ; Tue, 5 Mar 2019 05:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbfCEFvN (ORCPT ); Tue, 5 Mar 2019 00:51:13 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:38856 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfCEFvN (ORCPT ); Tue, 5 Mar 2019 00:51:13 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x255mOrT002400; Tue, 5 Mar 2019 14:48:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x255mOrT002400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551764905; bh=upricv6fVewsTKjghecoorebp9rRB3J2zizg4F0dOiY=; h=From:To:Cc:Subject:Date:From; b=psm7CSLg9BijV5QYpGE7GbBhhpCAe6mQnyl8ySC3xeg5QAvvvV2LEjloeMRip4SuO 2kD4bgx5yeh6gsItH3WqMtheJsOinOTNWDSkqCaCHdapoi7PslPNlh1UyUqJQt42z3 fp0gYP6WGCbaZ7BtpQU0jH2CseNNfhqaCEdYBkjtGob5ziN5Lrq086s0RBMFlKaJWf wIsne5C7SFaF2Rrw26bvyNF2+KySQs3JU2Ckj2qIEsEEO1n2WLsH3MS+RDuw+DJ0Y0 AHoB6iwdxKKOQ2bjdDLI1Befkmb4Zqm2Ga+H85C09Z8gGDazZNktbbsBOjIZPd1CkG KeIp+b3UH59Fg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra Cc: Thomas Gleixner , Douglas Anderson , Robin Meijboom , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Linus Torvalds , Sam Ravnborg , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] tools: move initial declarations out of 'for' loop Date: Tue, 5 Mar 2019 14:48:14 +0900 Message-Id: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When I was trying to compile this code for hostprogs-y notation of Kbuild, I was hit by the following error. error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode This is because KBUILD_HOSTCFLAGS specifies -std=gnu89 whereas the tools Makefile compiles it with -std=gnu99. Of course, it would be possible to pass -std=gnu99 per file, but it shouldn't hurt to fix the C code. Signed-off-by: Masahiro Yamada --- tools/lib/subcmd/parse-options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index dbb9efb..1bd858a2 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -630,6 +630,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o const char *const subcommands[], const char *usagestr[], int flags) { struct parse_opt_ctx_t ctx; + int i; /* build usage string if it's not provided */ if (subcommands && !usagestr[0]) { @@ -637,7 +638,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o astrcatf(&buf, "%s %s [] {", subcmd_config.exec_name, argv[0]); - for (int i = 0; subcommands[i]; i++) { + for (i = 0; subcommands[i]; i++) { if (i) astrcat(&buf, "|"); astrcat(&buf, subcommands[i]); @@ -663,7 +664,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o exit(130); case PARSE_OPT_LIST_SUBCMDS: if (subcommands) { - for (int i = 0; subcommands[i]; i++) + for (i = 0; subcommands[i]; i++) printf("%s ", subcommands[i]); } putchar('\n');