Skip to content
Snippets Groups Projects
Commit 7098f838 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
Link: https://github.com/ClangBuiltLinux/linux/issues/1929


Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Change-Id: I41f17964f3d0822b026f6ae8f06a4d49bc7f15a9
(cherry picked from https://android-review.googlesource.com/q/commit:8f75dab19c30be65c740bd4abf9587714b3305dc)
parent 1fed2de8
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment