diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 13:07:42 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 15:00:57 +0100 |
commit | 254d1313ae5a69c08c9b93032aaaf3d6083cfc07 (patch) | |
tree | 067102a36abe6bf597c26a42d79018a1060c9007 /src/network | |
parent | cbff793ffb280d9d11e5d7b1dc3964276491bee8 (diff) | |
download | systemd-254d1313ae5a69c08c9b93032aaaf3d6083cfc07.tar.gz |
tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.
Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state
Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.
In some places, initialization is dropped if unnecessary.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/netdev/tuntap.c | 4 | ||||
-rw-r--r-- | src/network/networkctl.c | 2 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/network/netdev/tuntap.c b/src/network/netdev/tuntap.c index 39ea7c1d73..1a37ba3465 100644 --- a/src/network/netdev/tuntap.c +++ b/src/network/netdev/tuntap.c @@ -101,7 +101,7 @@ static int tuntap_take_fd(NetDev *netdev) { } static int netdev_create_tuntap(NetDev *netdev) { - _cleanup_close_ int fd = -1; + _cleanup_close_ int fd = -EBADF; struct ifreq ifr = {}; TunTap *t; int r; @@ -180,7 +180,7 @@ static void tuntap_init(NetDev *netdev) { t = TUNTAP(netdev); assert(t); - t->fd = -1; + t->fd = -EBADF; } static void tuntap_drop(NetDev *netdev) { diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 8146125fc8..357d38f5ea 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -711,7 +711,7 @@ static void acquire_wlan_link_info(LinkInfo *link) { static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, LinkInfo **ret) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL; _cleanup_(link_info_array_freep) LinkInfo *links = NULL; - _cleanup_close_ int fd = -1; + _cleanup_close_ int fd = -EBADF; size_t c = 0; int r; diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index f3ebeadd2c..7d067a8c46 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -235,7 +235,7 @@ static int manager_connect_udev(Manager *m) { static int manager_listen_fds(Manager *m, int *ret_rtnl_fd) { _cleanup_strv_free_ char **names = NULL; - int n, rtnl_fd = -1; + int n, rtnl_fd = -EBADF; assert(m); assert(ret_rtnl_fd); @@ -499,7 +499,7 @@ static int manager_set_keep_configuration(Manager *m) { } int manager_setup(Manager *m) { - _cleanup_close_ int rtnl_fd = -1; + _cleanup_close_ int rtnl_fd = -EBADF; int r; assert(m); @@ -583,7 +583,7 @@ int manager_new(Manager **ret, bool test_mode) { .online_state = _LINK_ONLINE_STATE_INVALID, .manage_foreign_routes = true, .manage_foreign_rules = true, - .ethtool_fd = -1, + .ethtool_fd = -EBADF, .dhcp_duid.type = DUID_TYPE_EN, .dhcp6_duid.type = DUID_TYPE_EN, .duid_product_uuid.type = DUID_TYPE_UUID, |