diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-10-11 19:34:21 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-01-09 19:43:42 -0500 |
commit | dfc40b59c95f4bc1773c4f03c72e0da18147e11c (patch) | |
tree | cdb1980064402c61c91870b3849cbd0349486e9e /src | |
parent | 35b4202e3ae82625f69417902f41de3edfbe6398 (diff) |
udev: use initialization instead of zeroing in one place
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udev-ctrl.c | 17 | ||||
-rw-r--r-- | src/udev/udevd.c | 5 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index f273fb1510..095fe9f52c 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -362,13 +362,18 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) { struct udev_ctrl_msg *uctrl_msg; ssize_t size; - struct msghdr smsg; struct cmsghdr *cmsg; struct iovec iov; - struct ucred *cred; char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; + struct msghdr smsg = { + .msg_iov = &iov, + .msg_iovlen = 1, + .msg_control = cred_msg, + .msg_controllen = sizeof(cred_msg), + }; + struct ucred *cred; - uctrl_msg = calloc(1, sizeof(struct udev_ctrl_msg)); + uctrl_msg = new0(struct udev_ctrl_msg, 1); if (uctrl_msg == NULL) return NULL; uctrl_msg->refcount = 1; @@ -403,11 +408,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) iov.iov_base = &uctrl_msg->ctrl_msg_wire; iov.iov_len = sizeof(struct udev_ctrl_msg_wire); - memset(&smsg, 0x00, sizeof(struct msghdr)); - smsg.msg_iov = &iov; - smsg.msg_iovlen = 1; - smsg.msg_control = cred_msg; - smsg.msg_controllen = sizeof(cred_msg); + size = recvmsg(conn->sock, &smsg, 0); if (size < 0) { log_error("unable to receive ctrl message: %m\n"); diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 122958e9ac..b769be7451 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -778,10 +778,11 @@ static void handle_signal(struct udev *udev, int signo) if (WIFEXITED(status)) { if (WEXITSTATUS(status) != 0) - log_error("worker [%u] exit with return code %i\n", pid, WEXITSTATUS(status)); + log_error("worker [%u] exit with return code %i\n", + pid, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { log_error("worker [%u] terminated by signal %i (%s)\n", - pid, WTERMSIG(status), strsignal(WTERMSIG(status))); + pid, WTERMSIG(status), strsignal(WTERMSIG(status))); } else if (WIFSTOPPED(status)) { log_error("worker [%u] stopped\n", pid); } else if (WIFCONTINUED(status)) { |