Commit 4aee33cb authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Treehugger Robot
Browse files

ANDROID: libsubcmd: Hoist iterator variable declarations in parse_options_subcommand()

When applying HOSTCFLAGS to the libsubcmd build to resolve a separate
issue, which contain '-std=gnu89' prior to commit 1e240781 ("Kbuild:
use -std=gnu11 for KBUILD_USERCFLAGS"), the following warning/error
occurs:

  parse-options.c:643:8: error: GCC does not allow variable declarations in for loop initializers before C99 [-Werror,-Wgcc-compat]
                  for (int i = 0; subcommands[i]; i++) {
                       ^
  parse-options.c:669:9: error: GCC does not allow variable declarations in for loop initializers before C99 [-Werror,-Wgcc-compat]
                          for (int i = 0; subcommands[i]; i++)
                               ^

This issue was never visible upstream, as commit 1e240781 ("Kbuild:
use -std=gnu11 for KBUILD_USERCFLAGS") was applied before
commit 13e07691 ("tools/resolve_btfids: Alter how HOSTCC is
forced"). Prior to the latter change, there was no '-std=' flag passed
to the libsubcmd build, so the default standard value was used, which
may be newer than C99.

To resolve this issue to unblock applying HOSTCFLAGS to libsubcmd, just
hoist the declarations out of the for loops.

Bug: 301145081
Change-Id: I41f17964f3d0822b026f6ae8f06a4d49bc7f15a9
Link: https://github.com/ClangBuiltLinux/linux/issues/1929


Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
parent cc1046e3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment