]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip address: Fix loop initial declarations are only allowed in C99
authorRoi Dayan <roid@mellanox.com>
Thu, 11 Jun 2020 17:35:43 +0000 (20:35 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 11 Jun 2020 22:05:20 +0000 (15:05 -0700)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/ipaddress.c

index 3b53933f41673a5366aa567f75e8d94640e1ec7b..f97eaff3dbbf2535e8021b39a8cb7860234d233a 100644 (file)
@@ -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];
        }