mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 14:40:31 +00:00
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.
This commit is contained in:
@@ -445,12 +445,9 @@ static int l2tp_create_tunnel(NetDev *netdev) {
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not find local address.");
|
||||
|
||||
if (t->local_address_type >= 0 && DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *str = NULL;
|
||||
|
||||
(void) in_addr_to_string(t->family, &local_address, &str);
|
||||
log_netdev_debug(netdev, "Local address %s acquired.", strna(str));
|
||||
}
|
||||
if (t->local_address_type >= 0 && DEBUG_LOGGING)
|
||||
log_netdev_debug(netdev, "Local address %s acquired.",
|
||||
IN_ADDR_TO_STRING(t->family, &local_address));
|
||||
|
||||
r = netdev_l2tp_create_message_tunnel(netdev, &local_address, &m);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user