linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Ingo Molnar <mingo@redhat.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Douglas Anderson <dianders@chromium.org>,
	Robin Meijboom <robin@meijboom.info>,
	Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	linux-kbuild@vger.kernel.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	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	[thread overview]
Message-ID: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> (raw)

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@socionext.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


             reply	other threads:[~2019-03-05  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05  5:48 Masahiro Yamada [this message]
2019-03-05  5:48 ` [PATCH 2/3] objtool: move stack-validation.txt to Documentation/ Masahiro Yamada
2019-03-05 14:44   ` Jonathan Corbet
2019-03-05  5:48 ` [PATCH 3/3] objtool: move tools/objtool/ to scripts/objtool/ Masahiro Yamada
2019-03-05 14:46   ` Josh Poimboeuf
2019-03-05 16:08     ` Masahiro Yamada
2019-03-05 16:36       ` Josh Poimboeuf
2019-03-05 16:59         ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=bp@alien8.de \
    --cc=dianders@chromium.org \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=robin@meijboom.info \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).