From 29804cc1e0f37ee34301530fd7f1eb8550be464e Mon Sep 17 00:00:00 2001 From: Greg KH Date: Fri, 31 Jan 2014 06:51:32 +0100 Subject: 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). --- src/libsystemd/sd-bus/bus-kernel.c | 4 ++-- src/libsystemd/sd-bus/bus-message.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libsystemd') diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index 0b5bae32d5..26cd806b55 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 4e95226c5d..323413406a 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 -- cgit v1.2.3-54-g00ecf