Skip to contentSkip to conversation

src/main.c: fix build with gcc <= 4.8

PATCH Applied Fabrice Fontaine 2 participants 2 messages Jun 7, 2020 – Jun 8, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 src/main.c: fix build with gcc <= 4.8

Since commit 719e44277f8e89323a87219b4d4bc7abac05b051, build with gcc <= 4.8 fails on:

main.c:186:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = IDX_INTERACTIVE + 1; i < NR_NFT_OPTIONS; ++i)
^

Fixes:
- http://autobuild.buildroot.org/results/cf2359b8311fe91f9335c91f2bb4a730c9f4c9dc

---
 src/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/main.c +2 -1
index d830c7a2..e248a347 100644
@@ -169,6 +169,7 @@ static void print_option(const struct nft_opt *opt)
 
 static void show_help(const char *name)
 {
+	size_t i;
 	printf("Usage: %s [ options ] [ cmds... ]\n"
 	       "\n"
 	       "Options:\n", name);
@@ -185,7 +186,7 @@ static void show_help(const char *name)
 
 	fputs("\n", stdout);
 
-	for (size_t i = IDX_INTERACTIVE + 1; i < NR_NFT_OPTIONS; ++i)
+	for (i = IDX_INTERACTIVE + 1; i < NR_NFT_OPTIONS; ++i)
 		print_option(&nft_options[i]);
 
 	fputs("\n", stdout);
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 6 lines · Fabrice Fontaine

Since commit 719e44277f8e89323a87219b4d4bc7abac05b051, build with gcc <= 4.8 fails on:

main.c:186:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (size_t i = IDX_INTERACTIVE + 1; i < NR_NFT_OPTIONS; ++i)
^

Applied, thanks.