[systemd-commits] src/boot src/bootchart src/bus-proxyd src/journal src/libsystemd src/libsystemd-daemon src/libudev src/python-systemd src/readahead src/shared src/test src/udev

Tom Gundersen tomegun at kemper.freedesktop.org
Fri Jan 31 02:55:37 PST 2014


 src/boot/boot-efi.c                 |    2 +-
 src/bootchart/svg.c                 |    2 +-
 src/bus-proxyd/bus-proxyd.c         |    2 +-
 src/journal/fsprg.c                 |    4 ++--
 src/journal/journal-file.c          |    4 ++--
 src/libsystemd-daemon/sd-daemon.c   |    7 ++++---
 src/libsystemd/sd-bus/bus-kernel.c  |    4 ++--
 src/libsystemd/sd-bus/bus-message.c |   12 ++++++------
 src/libudev/libudev-device.c        |    2 +-
 src/libudev/libudev-list.c          |    2 +-
 src/libudev/libudev-monitor.c       |   10 +++++-----
 src/python-systemd/_journal.c       |    3 ++-
 src/readahead/readahead-collect.c   |    2 +-
 src/shared/hashmap.c                |    2 +-
 src/shared/util.c                   |    4 ++--
 src/test/test-libudev.c             |    4 ++--
 src/udev/cdrom_id/cdrom_id.c        |    2 +-
 src/udev/scsi_id/scsi_serial.c      |   16 ++++++++--------
 src/udev/udev-builtin-input_id.c    |    2 +-
 src/udev/udev-ctrl.c                |    2 +-
 src/udev/udev-event.c               |    4 ++--
 src/udev/udev-rules.c               |    6 +++---
 src/udev/udevadm-monitor.c          |    4 ++--
 src/udev/udevd.c                    |   16 ++++++++--------
 24 files changed, 60 insertions(+), 58 deletions(-)

New commits:
commit 29804cc1e0f37ee34301530fd7f1eb8550be464e
Author: Greg KH <gregkh at linuxfoundation.org>
Date:   Fri Jan 31 06:51:32 2014 +0100

    use memzero(foo, length); for all memset(foo, 0, length); calls
    
    In trying to track down a stupid linker bug, I noticed a bunch of
    memset() calls that should be using memzero() to make it more "obvious"
    that the options are correct (i.e. 0 is not the length, but the data to
    set).  So fix up all current calls to memset(foo, 0, length) to
    memzero(foo, length).

diff --git a/src/boot/boot-efi.c b/src/boot/boot-efi.c
index 1c80126..4266525 100644
--- a/src/boot/boot-efi.c
+++ b/src/boot/boot-efi.c
@@ -69,7 +69,7 @@ static int get_boot_entries(struct boot_info *info) {
                 info->fw_entries = e;
 
                 e = &info->fw_entries[info->fw_entries_count];
-                memset(e, 0, sizeof(struct boot_info_entry));
+                memzero(e, sizeof(struct boot_info_entry));
                 e->order = -1;
 
                 err = efi_get_boot_option(list[i], &e->title, &e->part_uuid, &e->path);
diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index 97c8237..7438e47 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -1248,7 +1248,7 @@ static void svg_top_ten_pss(void) {
 void svg_do(const char *build) {
         struct ps_struct *ps;
 
-        memset(&str, 0, sizeof(str));
+        memzero(&str, sizeof(str));
 
         ps = ps_first;
 
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index ab9b836..5869d79 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -172,7 +172,7 @@ static int rename_service(sd_bus *a, sd_bus *b) {
                              uid, name);
 
                 if (m > w)
-                        memset(arg_command_line_buffer + w, 0, m - w);
+                        memzero(arg_command_line_buffer + w, m - w);
         }
 
         log_debug("Running on behalf of PID "PID_FMT" (%s), UID "UID_FMT" (%s), %s",
diff --git a/src/journal/fsprg.c b/src/journal/fsprg.c
index dd9a242..5c8d6d6 100644
--- a/src/journal/fsprg.c
+++ b/src/journal/fsprg.c
@@ -51,7 +51,7 @@ static void mpi_export(void *buf, size_t buflen, const gcry_mpi_t x) {
         assert(gcry_mpi_cmp_ui(x, 0) >= 0);
         len = (gcry_mpi_get_nbits(x) + 7) / 8;
         assert(len <= buflen);
-        memset(buf, 0, buflen);
+        memzero(buf, buflen);
         gcry_mpi_print(GCRYMPI_FMT_USG, buf + (buflen - len), len, &nwritten, x);
         assert(nwritten == len);
 }
@@ -306,7 +306,7 @@ void FSPRG_GenState0(void *state, const void *mpk, const void *seed, size_t seed
 
         memcpy(state, mpk, 2 + secpar / 8);
         mpi_export(state + 2 + 1 * secpar / 8, secpar / 8, x);
-        memset(state + 2 + 2 * secpar / 8, 0, 8);
+        memzero(state + 2 + 2 * secpar / 8, 8);
 
         gcry_mpi_release(n);
         gcry_mpi_release(x);
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index b3747e3..3a08111 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -560,7 +560,7 @@ static int journal_file_setup_data_hash_table(JournalFile *f) {
         if (r < 0)
                 return r;
 
-        memset(o->hash_table.items, 0, s);
+        memzero(o->hash_table.items, s);
 
         f->header->data_hash_table_offset = htole64(p + offsetof(Object, hash_table.items));
         f->header->data_hash_table_size = htole64(s);
@@ -586,7 +586,7 @@ static int journal_file_setup_field_hash_table(JournalFile *f) {
         if (r < 0)
                 return r;
 
-        memset(o->hash_table.items, 0, s);
+        memzero(o->hash_table.items, s);
 
         f->header->field_hash_table_offset = htole64(p + offsetof(Object, hash_table.items));
         f->header->field_hash_table_size = htole64(s);
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 94230c9..1a713ef 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -47,6 +47,7 @@
 #  include <mqueue.h>
 #endif
 
+#include "util.h"
 #include "sd-daemon.h"
 
 #if (__GNUC__ >= 4)
@@ -441,18 +442,18 @@ _sd_export_ int sd_notify(int unset_environment, const char *state) {
                 goto finish;
         }
 
-        memset(&sockaddr, 0, sizeof(sockaddr));
+        memzero(&sockaddr, sizeof(sockaddr));
         sockaddr.sa.sa_family = AF_UNIX;
         strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
 
         if (sockaddr.un.sun_path[0] == '@')
                 sockaddr.un.sun_path[0] = 0;
 
-        memset(&iovec, 0, sizeof(iovec));
+        memzero(&iovec, sizeof(iovec));
         iovec.iov_base = (char*) state;
         iovec.iov_len = strlen(state);
 
-        memset(&msghdr, 0, sizeof(msghdr));
+        memzero(&msghdr, sizeof(msghdr));
         msghdr.msg_name = &sockaddr;
         msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
 
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 0b5bae3..26cd806 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -140,7 +140,7 @@ static int bus_message_setup_bloom(sd_bus_message *m, struct kdbus_bloom_filter
         assert(bloom);
 
         data = bloom->data;
-        memset(data, 0, m->bus->bloom_size);
+        memzero(data, m->bus->bloom_size);
         bloom->generation = 0;
 
         bloom_add_pair(data, m->bus->bloom_size, m->bus->bloom_n_hash, "message-type", bus_message_type_to_string(m->header->type));
@@ -256,7 +256,7 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
         }
 
         m->free_kdbus = true;
-        memset(m->kdbus, 0, sz);
+        memzero(m->kdbus, sz);
 
         m->kdbus->flags =
                 ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_FLAGS_EXPECT_REPLY) |
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 4e95226..3234134 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -194,7 +194,7 @@ static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
 
         /* Zero out padding */
         if (start > old_size)
-                memset((uint8_t*) np + old_size, 0, start - old_size);
+                memzero((uint8_t*) np + old_size, start - old_size);
 
         op = m->header;
         m->header = np;
@@ -252,7 +252,7 @@ static int message_append_field_string(
                         return -ENOMEM;
 
                 p[0] = h;
-                memset(p+1, 0, 7);
+                memzero(p+1, 7);
                 memcpy(p+8, s, l);
                 p[8+l] = 0;
                 p[8+l+1] = 0;
@@ -337,7 +337,7 @@ static int message_append_field_uint32(sd_bus_message *m, uint8_t h, uint32_t x)
                         return -ENOMEM;
 
                 p[0] = h;
-                memset(p+1, 0, 7);
+                memzero(p+1, 7);
                 *((uint32_t*) (p + 8)) = x;
                 p[12] = 0;
                 p[13] = 'u';
@@ -1228,7 +1228,7 @@ static void *message_extend_body(sd_bus_message *m, size_t align, size_t sz, boo
                                 return NULL;
 
                         if (padding > 0) {
-                                memset(p, 0, padding);
+                                memzero(p, padding);
                                 p = (uint8_t*) p + padding;
                         }
 
@@ -2514,7 +2514,7 @@ _public_ int sd_bus_message_append_array_iovec(
                 if (iov[i].iov_base)
                         memcpy(p, iov[i].iov_base, iov[i].iov_len);
                 else
-                        memset(p, 0, iov[i].iov_len);
+                        memzero(p, iov[i].iov_len);
 
                 p = (uint8_t*) p + iov[i].iov_len;
         }
@@ -2779,7 +2779,7 @@ int bus_message_seal(sd_bus_message *m, uint64_t cookie, usec_t timeout) {
         l = BUS_MESSAGE_FIELDS_SIZE(m);
         a = ALIGN8(l) - l;
         if (a > 0)
-                memset((uint8_t*) BUS_MESSAGE_FIELDS(m) + l, 0, a);
+                memzero((uint8_t*) BUS_MESSAGE_FIELDS(m) + l, a);
 
         /* If this is something we can send as memfd, then let's seal
         the memfd now. Note that we can send memfds as payload only
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 06fadf6..38144e3 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -810,7 +810,7 @@ _public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, c
                 sk = socket(PF_INET, SOCK_DGRAM, 0);
                 if (sk < 0)
                         return NULL;
-                memset(&ifr, 0x00, sizeof(struct ifreq));
+                memzero(&ifr, sizeof(struct ifreq));
                 ifr.ifr_ifindex = ifindex;
                 if (ioctl(sk, SIOCGIFNAME, &ifr) != 0) {
                         close(sk);
diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c
index 1cf53b0..c6e5a61 100644
--- a/src/libudev/libudev-list.c
+++ b/src/libudev/libudev-list.c
@@ -95,7 +95,7 @@ static inline struct udev_list_entry *list_node_to_entry(struct udev_list_node *
 
 void udev_list_init(struct udev *udev, struct udev_list *list, bool unique)
 {
-        memset(list, 0x00, sizeof(struct udev_list));
+        memzero(list, sizeof(struct udev_list));
         list->udev = udev;
         list->unique = unique;
         udev_list_node_init(&list->node);
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index ea7263f..f976da0 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -291,7 +291,7 @@ _public_ int udev_monitor_filter_update(struct udev_monitor *udev_monitor)
             udev_list_get_entry(&udev_monitor->filter_tag_list) == NULL)
                 return 0;
 
-        memset(ins, 0x00, sizeof(ins));
+        memzero(ins, sizeof(ins));
         i = 0;
 
         /* load magic in A */
@@ -371,7 +371,7 @@ _public_ int udev_monitor_filter_update(struct udev_monitor *udev_monitor)
         bpf_stmt(ins, &i, BPF_RET|BPF_K, 0xffffffff);
 
         /* install filter */
-        memset(&filter, 0x00, sizeof(filter));
+        memzero(&filter, sizeof(filter));
         filter.len = i;
         filter.filter = ins;
         err = setsockopt(udev_monitor->sock, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter));
@@ -599,7 +599,7 @@ retry:
                 return NULL;
         iov.iov_base = &buf;
         iov.iov_len = sizeof(buf);
-        memset (&smsg, 0x00, sizeof(struct msghdr));
+        memzero(&smsg, sizeof(struct msghdr));
         smsg.msg_iov = &iov;
         smsg.msg_iovlen = 1;
         smsg.msg_control = cred_msg;
@@ -744,7 +744,7 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
                 return -EINVAL;
 
         /* add versioned header */
-        memset(&nlh, 0x00, sizeof(struct udev_monitor_netlink_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);
@@ -771,7 +771,7 @@ int udev_monitor_send_device(struct udev_monitor *udev_monitor,
         iov[1].iov_base = (char *)buf;
         iov[1].iov_len = blen;
 
-        memset(&smsg, 0x00, sizeof(struct msghdr));
+        memzero(&smsg, sizeof(struct msghdr));
         smsg.msg_iov = iov;
         smsg.msg_iovlen = 2;
         /*
diff --git a/src/python-systemd/_journal.c b/src/python-systemd/_journal.c
index f8e0b4f..669c22c 100644
--- a/src/python-systemd/_journal.c
+++ b/src/python-systemd/_journal.c
@@ -22,6 +22,7 @@
 #include <Python.h>
 
 #include <alloca.h>
+#include "util.h"
 
 #define SD_JOURNAL_SUPPRESS_LOCATION
 #include <systemd/sd-journal.h>
@@ -41,7 +42,7 @@ static PyObject *journal_sendv(PyObject *self, PyObject *args) {
         /* Allocate an array for the argument strings */
         argc = PyTuple_Size(args);
         encoded = alloca(argc * sizeof(PyObject*));
-        memset(encoded, 0, argc * sizeof(PyObject*));
+        memzero(encoded, argc * sizeof(PyObject*));
 
         /* Allocate sufficient iovector space for the arguments. */
         iov = alloca(argc * sizeof(struct iovec));
diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c
index 58b77bd..211ef95 100644
--- a/src/readahead/readahead-collect.c
+++ b/src/readahead/readahead-collect.c
@@ -130,7 +130,7 @@ static int pack_file(FILE *pack, const char *fn, bool on_btrfs) {
 
         pages = l / page_size();
         vec = alloca(pages);
-        memset(vec, 0, pages);
+        memzero(vec, pages);
         if (mincore(start, l, vec) < 0) {
                 log_warning("mincore(%s) failed: %m", fn);
                 r = -errno;
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index b1dccaf..65b7b74 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -201,7 +201,7 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
                 if (!h)
                         return NULL;
 
-                memset(h, 0, size);
+                memzero(h, size);
         } else {
                 h = malloc0(size);
 
diff --git a/src/shared/util.c b/src/shared/util.c
index 4c5b048..aae5872 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2337,7 +2337,7 @@ void rename_process(const char name[8]) {
                         if (!saved_argv[i])
                                 break;
 
-                        memset(saved_argv[i], 0, strlen(saved_argv[i]));
+                        memzero(saved_argv[i], strlen(saved_argv[i]));
                 }
         }
 }
@@ -5792,7 +5792,7 @@ void* greedy_realloc0(void **p, size_t *allocated, size_t need) {
                 return NULL;
 
         if (*allocated > prev)
-                memset(&q[prev], 0, *allocated - prev);
+                memzero(&q[prev], *allocated - prev);
 
         return q;
 }
diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c
index a8c1ff0..c233b1e 100644
--- a/src/test/test-libudev.c
+++ b/src/test/test-libudev.c
@@ -253,7 +253,7 @@ static int test_monitor(struct udev *udev) {
                 goto out;
         }
 
-        memset(&ep_udev, 0, sizeof(struct epoll_event));
+        memzero(&ep_udev, sizeof(struct epoll_event));
         ep_udev.events = EPOLLIN;
         ep_udev.data.fd = fd_udev;
         if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
@@ -261,7 +261,7 @@ static int test_monitor(struct udev *udev) {
                 goto out;
         }
 
-        memset(&ep_stdin, 0, sizeof(struct epoll_event));
+        memzero(&ep_stdin, sizeof(struct epoll_event));
         ep_stdin.events = EPOLLIN;
         ep_stdin.data.fd = STDIN_FILENO;
         if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, STDIN_FILENO, &ep_stdin) < 0) {
diff --git a/src/udev/cdrom_id/cdrom_id.c b/src/udev/cdrom_id/cdrom_id.c
index c62fbf9..02a4d39 100644
--- a/src/udev/cdrom_id/cdrom_id.c
+++ b/src/udev/cdrom_id/cdrom_id.c
@@ -155,7 +155,7 @@ struct scsi_cmd {
 
 static void scsi_cmd_init(struct udev *udev, struct scsi_cmd *cmd)
 {
-        memset(cmd, 0x00, sizeof(struct scsi_cmd));
+        memzero(cmd, sizeof(struct scsi_cmd));
         cmd->cgc.quiet = 1;
         cmd->cgc.sense = &cmd->_sense.s;
         cmd->sg_io.interface_id = 'S';
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index 66e752e..2f2afce 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -331,7 +331,7 @@ static int scsi_inquiry(struct udev *udev,
 
 resend:
         if (dev_scsi->use_sg == 4) {
-                memset(&io_v4, 0, sizeof(struct sg_io_v4));
+                memzero(&io_v4, sizeof(struct sg_io_v4));
                 io_v4.guard = 'Q';
                 io_v4.protocol = BSG_PROTOCOL_SCSI;
                 io_v4.subprotocol = BSG_SUB_PROTOCOL_SCSI_CMD;
@@ -343,7 +343,7 @@ resend:
                 io_v4.din_xferp = (uintptr_t)buf;
                 io_buf = (void *)&io_v4;
         } else {
-                memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
+                memzero(&io_hdr, sizeof(struct sg_io_hdr));
                 io_hdr.interface_id = 'S';
                 io_hdr.cmd_len = sizeof(inq_cmd);
                 io_hdr.mx_sb_len = sizeof(sense);
@@ -410,7 +410,7 @@ static int do_scsi_page0_inquiry(struct udev *udev,
 {
         int retval;
 
-        memset(buffer, 0, len);
+        memzero(buffer, len);
         retval = scsi_inquiry(udev, dev_scsi, fd, 1, 0x0, buffer, len);
         if (retval < 0)
                 return 1;
@@ -622,7 +622,7 @@ static int do_scsi_page83_inquiry(struct udev *udev,
         /* also pick up the page 80 serial number */
         do_scsi_page80_inquiry(udev, dev_scsi, fd, NULL, unit_serial_number, MAX_SERIAL_LEN);
 
-        memset(page_83, 0, SCSI_INQ_BUFF_LEN);
+        memzero(page_83, SCSI_INQ_BUFF_LEN);
         retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_83, page_83,
                               SCSI_INQ_BUFF_LEN);
         if (retval < 0)
@@ -709,7 +709,7 @@ static int do_scsi_page83_prespc3_inquiry(struct udev *udev,
         int i, j;
         unsigned char page_83[SCSI_INQ_BUFF_LEN];
 
-        memset(page_83, 0, SCSI_INQ_BUFF_LEN);
+        memzero(page_83, SCSI_INQ_BUFF_LEN);
         retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_83, page_83, SCSI_INQ_BUFF_LEN);
         if (retval < 0)
                 return 1;
@@ -773,7 +773,7 @@ static int do_scsi_page80_inquiry(struct udev *udev,
         int len;
         unsigned char buf[SCSI_INQ_BUFF_LEN];
 
-        memset(buf, 0, SCSI_INQ_BUFF_LEN);
+        memzero(buf, SCSI_INQ_BUFF_LEN);
         retval = scsi_inquiry(udev, dev_scsi, fd, 1, PAGE_80, buf, SCSI_INQ_BUFF_LEN);
         if (retval < 0)
                 return retval;
@@ -832,7 +832,7 @@ int scsi_std_inquiry(struct udev *udev,
         sprintf(dev_scsi->kernel,"%d:%d", major(statbuf.st_rdev),
                 minor(statbuf.st_rdev));
 
-        memset(buf, 0, SCSI_INQ_BUFF_LEN);
+        memzero(buf, SCSI_INQ_BUFF_LEN);
         err = scsi_inquiry(udev, dev_scsi, fd, 0, 0, buf, SCSI_INQ_BUFF_LEN);
         if (err < 0)
                 goto out;
@@ -861,7 +861,7 @@ int scsi_get_serial(struct udev *udev,
         int ind;
         int retval;
 
-        memset(dev_scsi->serial, 0, len);
+        memzero(dev_scsi->serial, len);
         srand((unsigned int)getpid());
         for (cnt = 20; cnt > 0; cnt--) {
                 struct timespec duration;
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 4691fc0..9b99d1f 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -59,7 +59,7 @@ static void get_cap_mask(struct udev_device *dev,
         snprintf(text, sizeof(text), "%s", udev_device_get_sysattr_value(pdev, attr));
         log_debug("%s raw kernel attribute: %s", attr, text);
 
-        memset (bitmask, 0, bitmask_size);
+        memzero(bitmask, bitmask_size);
         i = 0;
         while ((word = strrchr(text, ' ')) != NULL) {
                 val = strtoul (word+1, NULL, 16);
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 2687986..a65603b 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -246,7 +246,7 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int
         struct udev_ctrl_msg_wire ctrl_msg_wire;
         int err = 0;
 
-        memset(&ctrl_msg_wire, 0x00, sizeof(struct udev_ctrl_msg_wire));
+        memzero(&ctrl_msg_wire, sizeof(struct udev_ctrl_msg_wire));
         strcpy(ctrl_msg_wire.version, "udev-" VERSION);
         ctrl_msg_wire.magic = UDEV_CTRL_MAGIC;
         ctrl_msg_wire.type = type;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 5aec077..228232b 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -439,7 +439,7 @@ static void spawn_read(struct udev_event *event,
         }
 
         if (fd_stdout >= 0) {
-                memset(&ep_outpipe, 0, sizeof(struct epoll_event));
+                memzero(&ep_outpipe, sizeof(struct epoll_event));
                 ep_outpipe.events = EPOLLIN;
                 ep_outpipe.data.ptr = &fd_stdout;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stdout, &ep_outpipe) < 0) {
@@ -449,7 +449,7 @@ static void spawn_read(struct udev_event *event,
         }
 
         if (fd_stderr >= 0) {
-                memset(&ep_errpipe, 0, sizeof(struct epoll_event));
+                memzero(&ep_errpipe, sizeof(struct epoll_event));
                 ep_errpipe.events = EPOLLIN;
                 ep_errpipe.data.ptr = &fd_stderr;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_stderr, &ep_errpipe) < 0) {
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 855a4e4..e908298 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -870,7 +870,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
         struct token *token = &rule_tmp->token[rule_tmp->token_cur];
         const char *attr = NULL;
 
-        memset(token, 0x00, sizeof(struct token));
+        memzero(token, sizeof(struct token));
 
         switch (type) {
         case TK_M_ACTION:
@@ -1052,7 +1052,7 @@ static int add_rule(struct udev_rules *rules, char *line,
         const char *attr;
         struct rule_tmp rule_tmp;
 
-        memset(&rule_tmp, 0x00, sizeof(struct rule_tmp));
+        memzero(&rule_tmp, sizeof(struct rule_tmp));
         rule_tmp.rules = rules;
         rule_tmp.rule.type = TK_RULE;
         /* the offset in the rule is limited to unsigned short */
@@ -1652,7 +1652,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
 
         strv_free(files);
 
-        memset(&end_token, 0x00, sizeof(struct token));
+        memzero(&end_token, sizeof(struct token));
         end_token.type = TK_END;
         add_token(rules, &end_token);
         log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 6022e8d..b2f7f6b 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -194,7 +194,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                         return 2;
                 }
 
-                memset(&ep_udev, 0, sizeof(struct epoll_event));
+                memzero(&ep_udev, sizeof(struct epoll_event));
                 ep_udev.events = EPOLLIN;
                 ep_udev.data.fd = fd_udev;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_udev, &ep_udev) < 0) {
@@ -228,7 +228,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
                         return 4;
                 }
 
-                memset(&ep_kernel, 0, sizeof(struct epoll_event));
+                memzero(&ep_kernel, sizeof(struct epoll_event));
                 ep_kernel.events = EPOLLIN;
                 ep_kernel.data.fd = fd_kernel;
                 if (epoll_ctl(fd_ep, EPOLL_CTL_ADD, fd_kernel, &ep_kernel) < 0) {
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 0dfad76..dca62f2 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -247,12 +247,12 @@ static void worker_new(struct event *event)
                         goto out;
                 }
 
-                memset(&ep_signal, 0, sizeof(struct epoll_event));
+                memzero(&ep_signal, sizeof(struct epoll_event));
                 ep_signal.events = EPOLLIN;
                 ep_signal.data.fd = fd_signal;
 
                 fd_monitor = udev_monitor_get_fd(worker_monitor);
-                memset(&ep_monitor, 0, sizeof(struct epoll_event));
+                memzero(&ep_monitor, sizeof(struct epoll_event));
                 ep_monitor.events = EPOLLIN;
                 ep_monitor.data.fd = fd_monitor;
 
@@ -303,7 +303,7 @@ static void worker_new(struct event *event)
                         udev_monitor_send_device(worker_monitor, NULL, dev);
 
                         /* send udevd the result of the event execution */
-                        memset(&msg, 0, sizeof(struct worker_message));
+                        memzero(&msg, sizeof(struct worker_message));
                         if (err != 0)
                                 msg.exitcode = err;
                         msg.pid = getpid();
@@ -1159,23 +1159,23 @@ int main(int argc, char *argv[])
                 goto exit;
         }
 
-        memset(&ep_ctrl, 0, sizeof(struct epoll_event));
+        memzero(&ep_ctrl, sizeof(struct epoll_event));
         ep_ctrl.events = EPOLLIN;
         ep_ctrl.data.fd = fd_ctrl;
 
-        memset(&ep_inotify, 0, sizeof(struct epoll_event));
+        memzero(&ep_inotify, sizeof(struct epoll_event));
         ep_inotify.events = EPOLLIN;
         ep_inotify.data.fd = fd_inotify;
 
-        memset(&ep_signal, 0, sizeof(struct epoll_event));
+        memzero(&ep_signal, sizeof(struct epoll_event));
         ep_signal.events = EPOLLIN;
         ep_signal.data.fd = fd_signal;
 
-        memset(&ep_netlink, 0, sizeof(struct epoll_event));
+        memzero(&ep_netlink, sizeof(struct epoll_event));
         ep_netlink.events = EPOLLIN;
         ep_netlink.data.fd = fd_netlink;
 
-        memset(&ep_worker, 0, sizeof(struct epoll_event));
+        memzero(&ep_worker, sizeof(struct epoll_event));
         ep_worker.events = EPOLLIN;
         ep_worker.data.fd = fd_worker;
 



More information about the systemd-commits mailing list