netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Cc: dsahern@gmail.com
Subject: [PATCH iproute2-next v3 2/9] ipaddress: ll_map: Replace ll_idx_n2a() with ll_index_to_name()
Date: Wed, 14 Feb 2018 23:37:38 +0200	[thread overview]
Message-ID: <1518644265-13093-3-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1518644265-13093-1-git-send-email-serhe.popovych@gmail.com>

There is no reentrancy as well as deferred result usage for all cases
where ll_idx_n2a() being used: it is safe to use ll_index_to_name() that
internally calls ll_idx_n2a() with static buffer to hold result.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
 ip/ipaddress.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index ad69d09..6b8295d 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -813,14 +813,13 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
 		print_bool(PRINT_ANY, "deleted", "Deleted ", true);
 
 	if (tb[IFLA_LINK]) {
-		SPRINT_BUF(b1);
 		int iflink = rta_getattr_u32(tb[IFLA_LINK]);
 
 		if (iflink == 0) {
 			snprintf(buf, sizeof(buf), "%s@NONE", name);
 			print_null(PRINT_JSON, "link", NULL, NULL);
 		} else {
-			const char *link = ll_idx_n2a(iflink, b1);
+			const char *link = ll_index_to_name(iflink);
 
 			print_string(PRINT_JSON, "link", NULL, link);
 			snprintf(buf, sizeof(buf), "%s@%s", name, link);
@@ -957,12 +956,10 @@ int print_linkinfo(const struct sockaddr_nl *who,
 				print_int(PRINT_ANY,
 					  "link_index", "@if%d: ", iflink);
 			else {
-				SPRINT_BUF(b1);
-
 				print_string(PRINT_ANY,
 					     "link",
 					     "@%s: ",
-					     ll_idx_n2a(iflink, b1));
+					     ll_index_to_name(iflink));
 				m_flag = ll_index_to_flags(iflink);
 				m_flag = !(m_flag & IFF_UP);
 			}
@@ -984,12 +981,12 @@ int print_linkinfo(const struct sockaddr_nl *who,
 			     "qdisc %s ",
 			     rta_getattr_str(tb[IFLA_QDISC]));
 	if (tb[IFLA_MASTER]) {
-		SPRINT_BUF(b1);
+		int master = rta_getattr_u32(tb[IFLA_MASTER]);
 
 		print_string(PRINT_ANY,
 			     "master",
 			     "master %s ",
-			     ll_idx_n2a(rta_getattr_u32(tb[IFLA_MASTER]), b1));
+			     ll_index_to_name(master));
 	}
 
 	if (tb[IFLA_OPERSTATE])
@@ -1308,7 +1305,6 @@ static int get_filter(const char *arg)
 static int ifa_label_match_rta(int ifindex, const struct rtattr *rta)
 {
 	const char *label;
-	SPRINT_BUF(b1);
 
 	if (!filter.label)
 		return 0;
@@ -1316,7 +1312,7 @@ static int ifa_label_match_rta(int ifindex, const struct rtattr *rta)
 	if (rta)
 		label = RTA_DATA(rta);
 	else
-		label = ll_idx_n2a(ifindex, b1);
+		label = ll_index_to_name(ifindex);
 
 	return fnmatch(filter.label, label, 0);
 }
-- 
1.7.10.4

  parent reply	other threads:[~2018-02-14 21:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 21:37 [PATCH iproute2-next v3 0/9] ipaddress: Make print_linkinfo_brief() static Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 1/9] ipaddress: Abstract IFA_LABEL matching code Serhey Popovych
2018-02-14 21:37 ` Serhey Popovych [this message]
2018-02-14 21:37 ` [PATCH iproute2-next v3 3/9] utils: Reimplement ll_idx_n2a() and introduce ll_idx_a2n() Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 4/9] ipaddress: Improve print_linkinfo() Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 5/9] ipaddress: Simplify print_linkinfo_brief() and it's usage Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 6/9] lib: Correct object file dependencies Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 7/9] utils: Introduce and use get_ifname_rta() Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 8/9] utils: Introduce and use print_name_and_link() to print name@link Serhey Popovych
2018-02-14 21:37 ` [PATCH iproute2-next v3 9/9] ipaddress: Make print_linkinfo_brief() static Serhey Popovych

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518644265-13093-3-git-send-email-serhe.popovych@gmail.com \
    --to=serhe.popovych@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).