tree-wide: pass -EBADF to device_monitor_new_full()

Prompted by https://github.com/systemd/systemd/pull/36922#discussion_r2024940885.
This commit is contained in:
Yu Watanabe
2025-04-02 23:34:29 +09:00
parent 5833a3340c
commit fd386a6a9d
4 changed files with 6 additions and 6 deletions

View File

@@ -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));

View File

@@ -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);

View File

@@ -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");

View File

@@ -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;