diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/dhcp-identifier.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator.c | 13 | ||||
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 7 | ||||
-rw-r--r-- | src/libsystemd/sd-device/test-sd-device.c | 8 | ||||
-rw-r--r-- | src/libudev/libudev-device.c | 6 | ||||
-rw-r--r-- | src/network/networkd-link.c | 6 | ||||
-rw-r--r-- | src/nspawn/nspawn-network.c | 7 | ||||
-rw-r--r-- | src/rfkill/rfkill.c | 6 | ||||
-rw-r--r-- | src/systemd/sd-device.h | 2 |
9 files changed, 28 insertions, 33 deletions
diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c index 77c584ee60..794e3a6f54 100644 --- a/src/libsystemd-network/dhcp-identifier.c +++ b/src/libsystemd-network/dhcp-identifier.c @@ -158,14 +158,14 @@ int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_i if (detect_container() <= 0) { /* not in a container, udev will be around */ char ifindex_str[2 + DECIMAL_STR_MAX(int)]; - int initialized, r; + int r; sprintf(ifindex_str, "n%d", ifindex); if (sd_device_new_from_device_id(&device, ifindex_str) >= 0) { - r = sd_device_get_is_initialized(device, &initialized); + r = sd_device_get_is_initialized(device); if (r < 0) return r; - if (!initialized) + if (r == 0) /* not yet ready */ return -EBUSY; diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 187ea703c9..8329a3f909 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -458,8 +458,7 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator, FOREACH_DIRENT_ALL(dent, dir, return -errno) { _cleanup_(sd_device_unrefp) sd_device *device = NULL; char syspath[strlen(path) + 1 + strlen(dent->d_name) + 1]; - dev_t devnum; - int ifindex, initialized, k; + int initialized, k; if (dent->d_name[0] == '.') continue; @@ -478,9 +477,9 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator, continue; } - k = sd_device_get_is_initialized(device, &initialized); - if (k < 0) { - r = k; + initialized = sd_device_get_is_initialized(device); + if (initialized < 0) { + r = initialized; continue; } @@ -496,8 +495,8 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator, */ if (!enumerator->match_allow_uninitialized && !initialized && - (sd_device_get_devnum(device, &devnum) >= 0 || - sd_device_get_ifindex(device, &ifindex) >= 0)) + (sd_device_get_devnum(device, NULL) >= 0 || + sd_device_get_ifindex(device, NULL) >= 0)) continue; if (!match_parent(enumerator, device)) diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index a89c54bb87..d0f5e1efcf 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1374,19 +1374,16 @@ static int device_read_db(sd_device *device) { return device_read_db_aux(device, false); } -_public_ int sd_device_get_is_initialized(sd_device *device, int *initialized) { +_public_ int sd_device_get_is_initialized(sd_device *device) { int r; assert_return(device, -EINVAL); - assert_return(initialized, -EINVAL); r = device_read_db(device); if (r < 0) return r; - *initialized = device->is_initialized; - - return 0; + return device->is_initialized; } _public_ int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec) { diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index fe49a2012a..25ed3ecfea 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -29,7 +29,7 @@ static void test_sd_device_basic(void) { assert_se(r >= 0 || r == -ENOENT); r = sd_device_get_devnum(d, &devnum); - assert_se(r >= 0 || r == -ENOENT); + assert_se((r >= 0 && major(devnum) > 0) || r == -ENOENT); r = sd_device_get_ifindex(d, &i); assert_se((r >= 0 && i > 0) || r == -ENOENT); @@ -47,9 +47,9 @@ static void test_sd_device_basic(void) { r = sd_device_get_sysnum(d, &val); assert_se(r >= 0 || r == -ENOENT); - i = 0; - assert_se(sd_device_get_is_initialized(d, &i) >= 0); - if (i > 0) { + r = sd_device_get_is_initialized(d); + assert_se(r >= 0); + if (r > 0) { r = sd_device_get_usec_since_initialized(d, &usec); assert_se(r >= 0 || r == -ENODATA); } diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 1c3d67a8f5..b6ccef7d8e 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -819,17 +819,17 @@ _public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_ * Returns: 1 if the device is set up. 0 otherwise. **/ _public_ int udev_device_get_is_initialized(struct udev_device *udev_device) { - int r, initialized; + int r; assert_return(udev_device, -EINVAL); - r = sd_device_get_is_initialized(udev_device->device, &initialized); + r = sd_device_get_is_initialized(udev_device->device); if (r < 0) { errno = -r; return 0; } - return initialized; + return r; } /** diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 867322f8c7..08ea7b4139 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -3333,8 +3333,8 @@ ipv4ll_address_fail: int link_add(Manager *m, sd_netlink_message *message, Link **ret) { _cleanup_(sd_device_unrefp) sd_device *device = NULL; char ifindex_str[2 + DECIMAL_STR_MAX(int)]; - int initialized, r; Link *link; + int r; assert(m); assert(m->rtnl); @@ -3362,12 +3362,12 @@ int link_add(Manager *m, sd_netlink_message *message, Link **ret) { goto failed; } - r = sd_device_get_is_initialized(device, &initialized); + r = sd_device_get_is_initialized(device); if (r < 0) { log_link_warning_errno(link, r, "Could not determine whether the device is initialized or not: %m"); goto failed; } - if (!initialized) { + if (r == 0) { /* not yet ready */ log_link_debug(link, "link pending udev initialization..."); return 0; diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c index 997609bb8e..214fa40804 100644 --- a/src/nspawn/nspawn-network.c +++ b/src/nspawn/nspawn-network.c @@ -395,7 +395,7 @@ int remove_bridge(const char *bridge_name) { static int parse_interface(const char *name) { _cleanup_(sd_device_unrefp) sd_device *d = NULL; char ifi_str[2 + DECIMAL_STR_MAX(int)]; - int ifi, initialized, r; + int ifi, r; ifi = (int) if_nametoindex(name); if (ifi <= 0) @@ -406,11 +406,10 @@ static int parse_interface(const char *name) { if (r < 0) return log_error_errno(r, "Failed to get device for interface %s: %m", name); - r = sd_device_get_is_initialized(d, &initialized); + r = sd_device_get_is_initialized(d); if (r < 0) return log_error_errno(r, "Failed to determine whether interface %s is initialized or not: %m", name); - - if (!initialized) { + if (r == 0) { log_error("Network interface %s is not initialized yet.", name); return -EBUSY; } diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c index b7316313c4..9e7d201add 100644 --- a/src/rfkill/rfkill.c +++ b/src/rfkill/rfkill.c @@ -111,12 +111,12 @@ static int wait_for_initialized( _cleanup_(sd_event_unrefp) sd_event *event = NULL; _cleanup_(sd_device_unrefp) sd_device *d = NULL; struct DeviceMonitorData data = {}; - int initialized, r; + int r; assert(device); assert(ret); - if (sd_device_get_is_initialized(device, &initialized) >= 0 && initialized) { + if (sd_device_get_is_initialized(device) > 0) { *ret = sd_device_ref(device); return 0; } @@ -152,7 +152,7 @@ static int wait_for_initialized( return log_full_errno(IN_SET(r, -ENOENT, -ENXIO, -ENODEV) ? LOG_DEBUG : LOG_ERR, r, "Failed to open device '%s': %m", data.sysname); - if (sd_device_get_is_initialized(d, &initialized) >= 0 && initialized) { + if (sd_device_get_is_initialized(d) > 0) { *ret = TAKE_PTR(d); return 0; } diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h index 43fb4a0c2a..6453bd517f 100644 --- a/src/systemd/sd-device.h +++ b/src/systemd/sd-device.h @@ -59,7 +59,7 @@ int sd_device_get_devname(sd_device *device, const char **ret); int sd_device_get_sysname(sd_device *device, const char **ret); int sd_device_get_sysnum(sd_device *device, const char **ret); -int sd_device_get_is_initialized(sd_device *device, int *initialized); +int sd_device_get_is_initialized(sd_device *device); int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec); const char *sd_device_get_tag_first(sd_device *device); |