From: Yu Watanabe Date: Wed, 2 Apr 2025 14:34:29 +0000 (+0900) Subject: tree-wide: pass -EBADF to device_monitor_new_full() X-Git-Tag: v258-rc1~947 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd386a6a9d58735f3750cc4aeff25c2b837eb5f8;p=thirdparty%2Fsystemd.git tree-wide: pass -EBADF to device_monitor_new_full() Prompted by https://github.com/systemd/systemd/pull/36922#discussion_r2024940885. --- diff --git a/src/libsystemd/sd-device/test-sd-device-monitor.c b/src/libsystemd/sd-device/test-sd-device-monitor.c index 1cdeabbf21e..362ce0a85ee 100644 --- a/src/libsystemd/sd-device/test-sd-device-monitor.c +++ b/src/libsystemd/sd-device/test-sd-device-monitor.c @@ -56,11 +56,11 @@ static int monitor_handler(sd_device_monitor *m, sd_device *d, void *userdata) { static void prepare_monitor(sd_device_monitor **ret_server, sd_device_monitor **ret_client, union sockaddr_union *ret_address) { _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor_server = NULL, *monitor_client = NULL; - ASSERT_OK(device_monitor_new_full(&monitor_server, MONITOR_GROUP_NONE, -1)); + ASSERT_OK(device_monitor_new_full(&monitor_server, MONITOR_GROUP_NONE, -EBADF)); ASSERT_OK(sd_device_monitor_set_description(monitor_server, "sender")); ASSERT_OK(sd_device_monitor_start(monitor_server, NULL, NULL)); - ASSERT_OK(device_monitor_new_full(&monitor_client, MONITOR_GROUP_NONE, -1)); + ASSERT_OK(device_monitor_new_full(&monitor_client, MONITOR_GROUP_NONE, -EBADF)); ASSERT_OK(sd_device_monitor_set_description(monitor_client, "client")); ASSERT_OK(device_monitor_allow_unicast_sender(monitor_client, monitor_server)); ASSERT_OK(device_monitor_get_address(monitor_client, ret_address)); @@ -106,7 +106,7 @@ TEST(sd_device_monitor_is_running) { ASSERT_OK_ZERO(sd_device_monitor_is_running(NULL)); - ASSERT_OK(device_monitor_new_full(&m, MONITOR_GROUP_NONE, -1)); + ASSERT_OK(device_monitor_new_full(&m, MONITOR_GROUP_NONE, -EBADF)); ASSERT_OK_ZERO(sd_device_monitor_is_running(m)); ASSERT_OK(sd_device_monitor_start(m, NULL, NULL)); ASSERT_OK_POSITIVE(sd_device_monitor_is_running(m)); diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 55b6eb00f67..0e5f8d51738 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -73,7 +73,7 @@ _public_ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, c if (g < 0) return_with_errno(NULL, EINVAL); - r = device_monitor_new_full(&m, g, -1); + r = device_monitor_new_full(&m, g, -EBADF); if (r < 0) return_with_errno(NULL, r); diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 76b953c9179..b411d45b6db 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -66,7 +66,7 @@ static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_ const char *subsystem, *devtype, *tag; int r; - r = device_monitor_new_full(&monitor, sender, -1); + r = device_monitor_new_full(&monitor, sender, -EBADF); if (r < 0) return log_error_errno(r, "Failed to create netlink socket: %m"); diff --git a/src/udev/udevadm-wait.c b/src/udev/udevadm-wait.c index 39e31ad2bfe..c93039895b6 100644 --- a/src/udev/udevadm-wait.c +++ b/src/udev/udevadm-wait.c @@ -180,7 +180,7 @@ static int setup_monitor(sd_event *event, MonitorNetlinkGroup group, const char assert(event); assert(ret); - r = device_monitor_new_full(&monitor, group, /* fd = */ -1); + r = device_monitor_new_full(&monitor, group, -EBADF); if (r < 0) return r;