From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2 v5 5/7] ip6/tunnel: Unify encap_limit printing Date: Wed, 10 Jan 2018 17:53:13 +0200 Message-ID: <1515599595-27958-6-git-send-email-serhe.popovych@gmail.com> References: <1515599595-27958-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f68.google.com ([209.85.215.68]:37237 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965537AbeAJPx0 (ORCPT ); Wed, 10 Jan 2018 10:53:26 -0500 Received: by mail-lf0-f68.google.com with SMTP id f3so20369477lfe.4 for ; Wed, 10 Jan 2018 07:53:26 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id i18sm3383697ljb.45.2018.01.10.07.53.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 07:53:24 -0800 (PST) In-Reply-To: <1515599595-27958-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Use %u format specifier to print it in link_gre6.c and make code more readable. Signed-off-by: Serhey Popovych --- ip/link_gre6.c | 11 ++++------- ip/link_ip6tnl.c | 12 ++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 1205946..8014207 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 7000056..379eb33 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, -- 1.7.10.4