[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com>
Date: Tue, 5 Mar 2019 14:48:14 +0900
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
To: Ingo Molnar <mingo@...hat.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Douglas Anderson <dianders@...omium.org>,
Robin Meijboom <robin@...jboom.info>,
Borislav Petkov <bp@...en8.de>,
"H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sam Ravnborg <sam@...nborg.org>, linux-kbuild@...r.kernel.org,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] tools: move initial declarations out of 'for' loop
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 <yamada.masahiro@...ionext.com>
---
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 [<options>] {", 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');
--
2.7.4
Powered by blists - more mailing lists