]> Git Repo - qemu.git/commitdiff
nbd: Don't use cpu_to_*w() functions
authorPeter Maydell <[email protected]>
Fri, 10 Jun 2016 16:15:42 +0000 (17:15 +0100)
committerPaolo Bonzini <[email protected]>
Thu, 16 Jun 2016 16:39:04 +0000 (18:39 +0200)
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 <[email protected]>
Message-Id: <1465575342[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
nbd/client.c

index bb8981f4f46bc22a212d4b8c21f4eaf97f7acd07..6d9c74d62c4aa8634ab8e1e03d31c05762958cda 100644 (file)
@@ -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) {
This page took 0.024097 seconds and 4 git commands to generate.