From: Serhey Popovych Date: Wed, 10 Jan 2018 15:53:13 +0000 (+0200) Subject: ip6/tunnel: Unify encap_limit printing X-Git-Tag: v4.15.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3945d92b0d2671d85c9a06bc573cc2adcbfb08a;p=thirdparty%2Fiproute2.git ip6/tunnel: Unify encap_limit printing Use %u format specifier to print it in link_gre6.c and make code more readable. Signed-off-by: Serhey Popovych Signed-off-by: Stephen Hemminger --- diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 1205946f1..8014207db 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -433,18 +433,15 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) print_int(PRINT_JSON, "ttl", NULL, ttl); } - if (flags & IP6_TNL_F_IGN_ENCAP_LIMIT) + if (flags & IP6_TNL_F_IGN_ENCAP_LIMIT) { print_bool(PRINT_ANY, "ip6_tnl_f_ign_encap_limit", "encaplimit none ", true); - else if (tb[IFLA_GRE_ENCAP_LIMIT]) { - int encap_limit = rta_getattr_u8(tb[IFLA_GRE_ENCAP_LIMIT]); + } else if (tb[IFLA_GRE_ENCAP_LIMIT]) { + __u8 val = rta_getattr_u8(tb[IFLA_GRE_ENCAP_LIMIT]); - print_int(PRINT_ANY, - "encap_limit", - "encaplimit %d ", - encap_limit); + print_uint(PRINT_ANY, "encap_limit", "encaplimit %u ", val); } if (flags & IP6_TNL_F_USE_ORIG_FLOWLABEL) { diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c index 7000056b6..379eb3315 100644 --- a/ip/link_ip6tnl.c +++ b/ip/link_ip6tnl.c @@ -387,16 +387,16 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb print_uint(PRINT_ANY, "link_index", "dev %u ", link); } - if (flags & IP6_TNL_F_IGN_ENCAP_LIMIT) + if (flags & IP6_TNL_F_IGN_ENCAP_LIMIT) { print_bool(PRINT_ANY, "ip6_tnl_f_ign_encap_limit", "encaplimit none ", true); - else if (tb[IFLA_IPTUN_ENCAP_LIMIT]) - print_uint(PRINT_ANY, - "encap_limit", - "encaplimit %u ", - rta_getattr_u8(tb[IFLA_IPTUN_ENCAP_LIMIT])); + } else if (tb[IFLA_IPTUN_ENCAP_LIMIT]) { + __u8 val = rta_getattr_u8(tb[IFLA_IPTUN_ENCAP_LIMIT]); + + print_uint(PRINT_ANY, "encap_limit", "encaplimit %u ", val); + } if (tb[IFLA_IPTUN_TTL]) print_uint(PRINT_ANY,