summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-15 07:31:20 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-03-18 21:31:26 -0400
commit9b2f02162bf4ffecb1386d2fc75ca5648bb134ce (patch)
tree08afdc7420ae2e3b9061446c67e5bc75703e260d /src/libudev
parent59b6fb3b75063fbefa9f0f6132e0f3c5093517a9 (diff)
libudev-monitor: use initialization
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/libudev-monitor.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index d0486e3d1e..55965070b1 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -698,13 +698,20 @@ retry:
int udev_monitor_send_device(struct udev_monitor *udev_monitor,
struct udev_monitor *destination, struct udev_device *udev_device)
{
- const char *buf;
- ssize_t blen;
- ssize_t count;
- struct msghdr smsg;
- struct iovec iov[2];
- const char *val;
- struct udev_monitor_netlink_header nlh;
+ const char *buf, *val;
+ ssize_t blen, count;
+ struct udev_monitor_netlink_header nlh = {
+ .prefix = "libudev",
+ .magic = htonl(UDEV_MONITOR_MAGIC),
+ .header_size = sizeof nlh,
+ };
+ struct iovec iov[2] = {
+ { .iov_base = &nlh, .iov_len = sizeof nlh },
+ };
+ struct msghdr smsg = {
+ .msg_iov = iov,
+ .msg_iovlen = 2,
+ };
struct udev_list_entry *list_entry;
uint64_t tag_bloom_bits;
@@ -712,18 +719,13 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
if (blen < 32)
return -EINVAL;
- /* add versioned header */
- memzero(&nlh, sizeof(struct udev_monitor_netlink_header));
- memcpy(nlh.prefix, "libudev", 8);
- nlh.magic = htonl(UDEV_MONITOR_MAGIC);
- nlh.header_size = sizeof(struct udev_monitor_netlink_header);
+ /* fill in versioned header */
val = udev_device_get_subsystem(udev_device);
nlh.filter_subsystem_hash = htonl(util_string_hash32(val));
+
val = udev_device_get_devtype(udev_device);
if (val != NULL)
nlh.filter_devtype_hash = htonl(util_string_hash32(val));
- iov[0].iov_base = &nlh;
- iov[0].iov_len = sizeof(struct udev_monitor_netlink_header);
/* add tag bloom filter */
tag_bloom_bits = 0;
@@ -740,9 +742,6 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
iov[1].iov_base = (char *)buf;
iov[1].iov_len = blen;
- memzero(&smsg, sizeof(struct msghdr));
- smsg.msg_iov = iov;
- smsg.msg_iovlen = 2;
/*
* Use custom address for target, or the default one.
*