From a062a72f1b2e3c14d1c58afed4dfd8c268ac744d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 24 Aug 2018 16:47:30 +0900 Subject: libudev-monitor: rename monitor_set_nl_address() and make it return negative errno --- src/libudev/libudev-monitor.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/libudev') 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"); -- cgit v1.2.3