chiark / gitweb /
machinectl: use initialization instead of zeroing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 Oct 2013 03:32:27 +0000 (23:32 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Nov 2013 19:56:47 +0000 (14:56 -0500)
src/machine/machinectl.c

index 894309c7d27ebf1cff0cdb6dd21c323c7094ff4a..c48abcd0bb7aa51f41ffe5c57d1dec6b1021910b 100644 (file)
@@ -409,11 +409,14 @@ static int openpt_in_namespace(pid_t pid, int flags) {
         _cleanup_close_ int nsfd = -1, rootfd = -1;
         _cleanup_free_ char *ns = NULL, *root = NULL;
         _cleanup_close_pipe_ int sock[2] = { -1, -1 };
         _cleanup_close_ int nsfd = -1, rootfd = -1;
         _cleanup_free_ char *ns = NULL, *root = NULL;
         _cleanup_close_pipe_ int sock[2] = { -1, -1 };
-        struct msghdr mh;
         union {
                 struct cmsghdr cmsghdr;
                 uint8_t buf[CMSG_SPACE(sizeof(int))];
         union {
                 struct cmsghdr cmsghdr;
                 uint8_t buf[CMSG_SPACE(sizeof(int))];
-        } control;
+        } control = {};
+        struct msghdr mh = {
+                .msg_control = &control,
+                .msg_controllen = sizeof(control),
+        };
         struct cmsghdr *cmsg;
         int master = -1, r;
         pid_t child;
         struct cmsghdr *cmsg;
         int master = -1, r;
         pid_t child;
@@ -438,11 +441,6 @@ static int openpt_in_namespace(pid_t pid, int flags) {
         if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0)
                 return -errno;
 
         if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0)
                 return -errno;
 
-        zero(control);
-        zero(mh);
-        mh.msg_control = &control;
-        mh.msg_controllen = sizeof(control);
-
         child = fork();
         if (child < 0)
                 return -errno;
         child = fork();
         if (child < 0)
                 return -errno;