From 67a62589185f947a8757528818e090f9ae264738 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 21 Mar 2024 15:04:48 +1100 Subject: util: Add helper to return name of address family We have a few places where we want to include the name of the internet protocol version (IPv4 or IPv6) in a message, which we handle with an open-coded ?: expression. This seems like something that might be more widely useful, so make a trivial helper to return the correct string based on the address family. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'netlink.c') diff --git a/netlink.c b/netlink.c index 59e9e33..0549237 100644 --- a/netlink.c +++ b/netlink.c @@ -309,7 +309,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) if (defifi) { if (ndef > 1) info("Multiple default %s routes, picked first", - af == AF_INET ? "IPv4" : "IPv6"); + af_name(af)); return defifi; } @@ -318,11 +318,11 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) return anyifi; info("Multiple interfaces with %s routes, use -i to select one", - af == AF_INET ? "IPv4" : "IPv6"); + af_name(af)); } if (!nany) - info("No interfaces with %s routes", af == AF_INET ? "IPv4" : "IPv6"); + info("No interfaces with %s routes", af_name(af)); return 0; } -- cgit v1.2.3