From:  Stephen Hemminger
> Sent: 07 July 2017 16:40
> For the most of the address flags, use a table of bit values rather
> than open coding every value.  This allows for easier inevitable
> expansion of flags.
> 
> This also fixes the missing stable-privacy flag.
> 
> Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
> ---
>  ip/ipaddress.c | 152 
> ++++++++++++++++++++++++---------------------------------
>  1 file changed, 65 insertions(+), 87 deletions(-)
> 
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index f06f5829fb61..b4efb9fedcd2 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -1013,14 +1013,67 @@ static unsigned int get_ifa_flags(struct ifaddrmsg 
> *ifa,
>                               ifa->ifa_flags;
>  }
> 
> +
> +static const char *ifa_flag_names[] = {
> +     "secondary",
> +     "nodad",
> +     "optimistic",
> +     "dadfailed",
> +     "home",
> +     "deprecated",
> +     "tentative",
> +     "permanent",
> +     "mngtmpaddr",
> +     "noprefixroute",
> +     "autojoin",
> +     "stable-privacy",
> +};

It would be safer to set up a table of the constant - string pairs
instead of relying on the table being in the right order.

        David

Reply via email to