summaryrefslogtreecommitdiff
path: root/src/udev/udev-ctrl.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-11 19:34:21 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-13 17:56:55 -0400
commit97fec53e5e91222f43fc89d0ad45fa197742a363 (patch)
treea1af02728a4b3170f0a7e7eea5ffaa5e0c53c479 /src/udev/udev-ctrl.c
parent872c8faaf2009422a91d227ae0b5c6f04c9d2c69 (diff)
udev: use initialization instead of zeroing in one place
Diffstat (limited to 'src/udev/udev-ctrl.c')
-rw-r--r--src/udev/udev-ctrl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index e60da906c5..662bd33de8 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -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");