diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-03 11:24:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-06-06 09:52:52 +0200 |
commit | 84dbb3fd83ef7d7e5b2ea02be1f492974384256c (patch) | |
tree | 8b709e5d9f164c9b8297a08dc328bd9c92e01d83 /src/network/networkd-neighbor.c | |
parent | b547241728487c0dca22780241b04964f2eb37af (diff) | |
download | systemd-84dbb3fd83ef7d7e5b2ea02be1f492974384256c.tar.gz |
basic/in-addr-util: add IN_ADDR_TO_STRING
Since we don't need the error value, and the buffer is allocated with a fixed
size, the whole logic provided by in_addr_to_string() becomes unnecessary, so
it's enough to wrap inet_ntop() directly.
inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed
to be large enough, so this should never fail. A bunch of tests of this are added.
This allows all the wrappers like strna(), strnull(), strempty() to be dropped.
The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(),
because log_debug() implements the check outside of the function call. But
log_link_debug() does not, so it we need it to avoid unnecessary evaluation of
the formatting.
Diffstat (limited to 'src/network/networkd-neighbor.c')
-rw-r--r-- | src/network/networkd-neighbor.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c index 435fa7002e..f11f06001b 100644 --- a/src/network/networkd-neighbor.c +++ b/src/network/networkd-neighbor.c @@ -158,7 +158,7 @@ static int neighbor_add(Link *link, Neighbor *neighbor) { } static void log_neighbor_debug(const Neighbor *neighbor, const char *str, const Link *link) { - _cleanup_free_ char *state = NULL, *dst = NULL; + _cleanup_free_ char *state = NULL; assert(neighbor); assert(str); @@ -167,12 +167,12 @@ static void log_neighbor_debug(const Neighbor *neighbor, const char *str, const return; (void) network_config_state_to_string_alloc(neighbor->state, &state); - (void) in_addr_to_string(neighbor->family, &neighbor->in_addr, &dst); log_link_debug(link, "%s %s neighbor (%s): lladdr: %s, dst: %s", str, strna(network_config_source_to_string(neighbor->source)), strna(state), - HW_ADDR_TO_STR(&neighbor->ll_addr), strna(dst)); + HW_ADDR_TO_STR(&neighbor->ll_addr), + IN_ADDR_TO_STRING(neighbor->family, &neighbor->in_addr)); } static int neighbor_configure_message(Neighbor *neighbor, Link *link, sd_netlink_message *req) { |