summaryrefslogtreecommitdiffstats
path: root/src/libudev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-08-24 09:47:30 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-09-11 05:45:21 +0200
commita062a72f1b2e3c14d1c58afed4dfd8c268ac744d (patch)
treefcb1b286168afbd7a724fd7e7946d146a9a9a31f /src/libudev
parentlibudev-monitor: rename udev_has_devtmpfs() and move it to mount-util.c (diff)
downloadsystemd-a062a72f1b2e3c14d1c58afed4dfd8c268ac744d.tar.xz
systemd-a062a72f1b2e3c14d1c58afed4dfd8c268ac744d.zip
libudev-monitor: rename monitor_set_nl_address() and make it return negative errno
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-monitor.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index 5ca035d43c..0df112d245 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -94,20 +94,20 @@ static struct udev_monitor *udev_monitor_new(struct udev *udev) {
return udev_monitor;
}
-static void monitor_set_nl_address(struct udev_monitor *udev_monitor) {
+static int udev_monitor_set_nl_address(struct udev_monitor *udev_monitor) {
union sockaddr_union snl;
socklen_t addrlen;
- int r;
assert(udev_monitor);
- /* get the address the kernel has assigned us
- * it is usually, but not necessarily the pid
- */
+ /* Get the address the kernel has assigned us.
+ * It is usually, but not necessarily the pid. */
addrlen = sizeof(struct sockaddr_nl);
- r = getsockname(udev_monitor->sock, &snl.sa, &addrlen);
- if (r >= 0)
- udev_monitor->snl.nl.nl_pid = snl.nl.nl_pid;
+ if (getsockname(udev_monitor->sock, &snl.sa, &addrlen) < 0)
+ return -errno;
+
+ udev_monitor->snl.nl.nl_pid = snl.nl.nl_pid;
+ return 0;
}
struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const char *name, int fd) {
@@ -154,7 +154,7 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
} else {
udev_monitor->bound = true;
udev_monitor->sock = fd;
- monitor_set_nl_address(udev_monitor);
+ udev_monitor_set_nl_address(udev_monitor);
}
udev_monitor->snl.nl.nl_family = AF_NETLINK;
@@ -349,7 +349,7 @@ _public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
}
if (err >= 0)
- monitor_set_nl_address(udev_monitor);
+ udev_monitor_set_nl_address(udev_monitor);
else
return log_debug_errno(errno, "bind failed: %m");