summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-05-24 15:14:43 +0200
committerTom Gundersen <teg@jklm.no>2015-05-24 15:29:48 +0200
commit2dd9f98d2d7a06a8e28729da6339fce50d66e9cc (patch)
tree90950366f6a13870351d481ec6ec5f99e0905b3b /src/udev
parent6d1b1e0bc6bd020218afc5f05286bf372be283d5 (diff)
udevd: worker - modernize a bit
Initialize structs when declaring rather than using memzero().
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udevd.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index d8cb046e13..4a44b03143 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -316,10 +316,11 @@ static void worker_spawn(Manager *manager, struct event *event) {
switch (pid) {
case 0: {
struct udev_device *dev = NULL;
+ _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
int fd_monitor;
_cleanup_close_ int fd_signal = -1, fd_ep = -1;
- _cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
- struct epoll_event ep_signal, ep_monitor;
+ struct epoll_event ep_signal = { .events = EPOLLIN };
+ struct epoll_event ep_monitor = { .events = EPOLLIN };
sigset_t mask;
int r = 0;
@@ -345,6 +346,10 @@ static void worker_spawn(Manager *manager, struct event *event) {
r = log_error_errno(errno, "error creating signalfd %m");
goto out;
}
+ ep_signal.data.fd = fd_signal;
+
+ fd_monitor = udev_monitor_get_fd(worker_monitor);
+ ep_monitor.data.fd = fd_monitor;
fd_ep = epoll_create1(EPOLL_CLOEXEC);
if (fd_ep < 0) {
@@ -352,15 +357,6 @@ static void worker_spawn(Manager *manager, struct event *event) {
goto out;
}
- memzero(&ep_signal, sizeof(struct epoll_event));
- ep_signal.events = EPOLLIN;
- ep_signal.data.fd = fd_signal;
-
- fd_monitor = udev_monitor_get_fd(worker_monitor);
- memzero(&ep_monitor, sizeof(struct epoll_event));
- ep_monitor.events = EPOLLIN;
- ep_monitor.data.fd = fd_monitor;
-
if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_signal, &ep_signal) < 0 ||
epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_monitor, &ep_monitor) < 0) {
r = log_error_errno(errno, "fail to add fds to epoll: %m");