[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/30] nbd: Don't use cpu_to_*w() functions
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 10/30] nbd: Don't use cpu_to_*w() functions |
Date: |
Thu, 16 Jun 2016 16:16:05 +0200 |
From: Peter Maydell <address@hidden>
The cpu_to_*w() functions just compose a pointer dereference
with a byteswap. Instead use st*_p(), which handles potential
pointer misalignment and avoids the need to cast the pointer.
Signed-off-by: Peter Maydell <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
nbd/client.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/nbd/client.c b/nbd/client.c
index bb8981f..6d9c74d 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -686,11 +686,11 @@ ssize_t nbd_send_request(QIOChannel *ioc, struct
nbd_request *request)
"{ .from = %" PRIu64", .len = %u, .handle = %" PRIu64", .type=%i}",
request->from, request->len, request->handle, request->type);
- cpu_to_be32w((uint32_t*)buf, NBD_REQUEST_MAGIC);
- cpu_to_be32w((uint32_t*)(buf + 4), request->type);
- cpu_to_be64w((uint64_t*)(buf + 8), request->handle);
- cpu_to_be64w((uint64_t*)(buf + 16), request->from);
- cpu_to_be32w((uint32_t*)(buf + 24), request->len);
+ stl_be_p(buf, NBD_REQUEST_MAGIC);
+ stl_be_p(buf + 4, request->type);
+ stq_be_p(buf + 8, request->handle);
+ stq_be_p(buf + 16, request->from);
+ stl_be_p(buf + 24, request->len);
ret = write_sync(ioc, buf, sizeof(buf));
if (ret < 0) {
--
2.5.5
- [Qemu-devel] [PULL 00/30] KVM, build, NBD, SCSI patches for 2016-06-16, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 01/30] configure: Remove unused CONFIG_ZERO_MALLOC setting, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 04/30] configure: Enable -Werror for MinGW builds, too, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 07/30] avx2 configure: Use primitives in test, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 02/30] os-posix: include sys/mman.h, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 05/30] Makefile: Fix tag file generation targets, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 08/30] configure: Remove unused CONFIG_SIGEV_THREAD_ID switch, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 09/30] nbd: Don't use *_to_cpup() functions, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 03/30] clean-includes: run it once more, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 10/30] nbd: Don't use cpu_to_*w() functions,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/30] Make avx2 configure test work with -O2, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 12/30] target-i386: kvm: cache KVM_GET_SUPPORTED_CPUID data, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 14/30] linux-headers: update to Linux 4.6, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 13/30] scsi-disk: Use (unsigned long) typecasts when using "%lu" format string, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 11/30] nbd: simplify the nbd_request and nbd_reply structs, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 16/30] vl.c: Add '-L help' which lists data dirs., Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 15/30] KVM: use KVM_CAP_MAX_VCPU_ID, Paolo Bonzini, 2016/06/16
- [Qemu-devel] [PULL 17/30] nbd: Use BDRV_REQ_FUA for better FUA where supported, Paolo Bonzini, 2016/06/16