netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ip address: Fix loop initial declarations are only allowed in C99
@ 2020-06-11 17:35 Roi Dayan
  2020-06-11 22:05 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Roi Dayan @ 2020-06-11 17:35 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, David Ahern, Roi Dayan

On some distros, i.e. rhel 7.6, compilation fails with the following:

ipaddress.c: In function ‘lookup_flag_data_by_name’:
ipaddress.c:1260:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (int i = 0; i < ARRAY_SIZE(ifa_flag_data); ++i) {
  ^
ipaddress.c:1260:2: note: use option -std=c99 or -std=gnu99 to compile your code

This commit fixes the single place needed for compilation to pass.

Fixes: 9d59c86e575b ("iproute2: ip addr: Organize flag properties structurally")
Signed-off-by: Roi Dayan <roid@mellanox.com>
---
 ip/ipaddress.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 3b53933f4167..f97eaff3dbbf 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1257,7 +1257,9 @@ static const struct ifa_flag_data_t {
 
 /* Returns a pointer to the data structure for a particular interface flag, or null if no flag could be found */
 static const struct ifa_flag_data_t* lookup_flag_data_by_name(const char* flag_name) {
-	for (int i = 0; i < ARRAY_SIZE(ifa_flag_data); ++i) {
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(ifa_flag_data); ++i) {
 		if (strcmp(flag_name, ifa_flag_data[i].name) == 0)
 			return &ifa_flag_data[i];
 	}
-- 
2.8.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] ip address: Fix loop initial declarations are only allowed in C99
  2020-06-11 17:35 [PATCH iproute2] ip address: Fix loop initial declarations are only allowed in C99 Roi Dayan
@ 2020-06-11 22:05 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2020-06-11 22:05 UTC (permalink / raw)
  To: Roi Dayan; +Cc: netdev, David Ahern

On Thu, 11 Jun 2020 20:35:43 +0300
Roi Dayan <roid@mellanox.com> wrote:

> On some distros, i.e. rhel 7.6, compilation fails with the following:
> 
> ipaddress.c: In function ‘lookup_flag_data_by_name’:
> ipaddress.c:1260:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
>   for (int i = 0; i < ARRAY_SIZE(ifa_flag_data); ++i) {
>   ^
> ipaddress.c:1260:2: note: use option -std=c99 or -std=gnu99 to compile your code
> 
> This commit fixes the single place needed for compilation to pass.
> 
> Fixes: 9d59c86e575b ("iproute2: ip addr: Organize flag properties structurally")
> Signed-off-by: Roi Dayan <roid@mellanox.com>

Agree.
Applied

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-11 22:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-11 17:35 [PATCH iproute2] ip address: Fix loop initial declarations are only allowed in C99 Roi Dayan
2020-06-11 22:05 ` Stephen Hemminger

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).