diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-09-28 22:04:52 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-09-29 03:37:09 +0900 |
commit | 5977b71f28075c34eb9e45aaa2d7cdc791f7eaf8 (patch) | |
tree | 44f0e8caf628eae20a9be91e63b7f6b47d871551 /src/libsystemd-network/sd-ndisc.c | |
parent | 01afd0f7f53f7807294ce7c008ecf8a043a920fe (diff) | |
download | systemd-5977b71f28075c34eb9e45aaa2d7cdc791f7eaf8.tar.gz |
libsystemd-network: make sd_dhcp_client_get_ifname() or friends return negative errno on error
Diffstat (limited to 'src/libsystemd-network/sd-ndisc.c')
-rw-r--r-- | src/libsystemd-network/sd-ndisc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index 0c27b7ea72..65f75cc250 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -74,11 +74,19 @@ int sd_ndisc_set_ifname(sd_ndisc *nd, const char *ifname) { return free_and_strdup(&nd->ifname, ifname); } -const char *sd_ndisc_get_ifname(sd_ndisc *nd) { - if (!nd) - return NULL; +int sd_ndisc_get_ifname(sd_ndisc *nd, const char **ret) { + int r; + + assert_return(nd, -EINVAL); - return get_ifname(nd->ifindex, &nd->ifname); + r = get_ifname(nd->ifindex, &nd->ifname); + if (r < 0) + return r; + + if (ret) + *ret = nd->ifname; + + return 0; } _public_ int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr) { |