chiark / gitweb /
udev: use initialization instead of zeroing in one place
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Oct 2013 23:34:21 +0000 (19:34 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 13 Oct 2013 21:56:55 +0000 (17:56 -0400)
src/udev/udev-ctrl.c
src/udev/udevd.c

index e60da90..662bd33 100644 (file)
@@ -340,13 +340,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;
@@ -381,11 +386,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");
index 7c6c5d6..1c2d00f 100644 (file)
@@ -779,10 +779,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)) {