All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Juan Quintela <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	liang.z.li@intel.com, den@openvz.org,
	qemu list <qemu-devel@nongnu.org>,
	Amit Shah <amit.shah@redhat.com>
Subject: [Qemu-devel] [PULL 01/13] migration: Don't use *_to_cpup() and cpu_to_*w()
Date: Fri, 17 Jun 2016 18:36:40 +0530	[thread overview]
Message-ID: <4d885131574ba530e48ef90d5c0ca4dffc9c3759.1466168448.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1466168448.git.amit.shah@redhat.com>
In-Reply-To: <cover.1466168448.git.amit.shah@redhat.com>

From: Peter Maydell <peter.maydell@linaro.org>

The *_to_cpup() and cpu_to_*w() functions just compose a pointer
dereference with a byteswap. Instead use ld*_p() and st*_p(),
which handle potential pointer misalignment and avoid the need
to cast the pointer.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Message-Id: <1465574962-2710-1-git-send-email-peter.maydell@linaro.org>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 migration/migration.c | 12 ++++++------
 migration/savevm.c    |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 20f8875..a560136 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1384,7 +1384,7 @@ static void *source_return_path_thread(void *opaque)
         /* OK, we have the message and the data */
         switch (header_type) {
         case MIG_RP_MSG_SHUT:
-            sibling_error = be32_to_cpup((uint32_t *)buf);
+            sibling_error = ldl_be_p(buf);
             trace_source_return_path_thread_shut(sibling_error);
             if (sibling_error) {
                 error_report("RP: Sibling indicated error %d", sibling_error);
@@ -1398,13 +1398,13 @@ static void *source_return_path_thread(void *opaque)
             goto out;
 
         case MIG_RP_MSG_PONG:
-            tmp32 = be32_to_cpup((uint32_t *)buf);
+            tmp32 = ldl_be_p(buf);
             trace_source_return_path_thread_pong(tmp32);
             break;
 
         case MIG_RP_MSG_REQ_PAGES:
-            start = be64_to_cpup((uint64_t *)buf);
-            len = be32_to_cpup((uint32_t *)(buf + 8));
+            start = ldq_be_p(buf);
+            len = ldl_be_p(buf + 8);
             migrate_handle_rp_req_pages(ms, NULL, start, len);
             break;
 
@@ -1412,8 +1412,8 @@ static void *source_return_path_thread(void *opaque)
             expected_len = 12 + 1; /* header + termination */
 
             if (header_len >= expected_len) {
-                start = be64_to_cpup((uint64_t *)buf);
-                len = be32_to_cpup((uint32_t *)(buf + 8));
+                start = ldq_be_p(buf);
+                len = ldl_be_p(buf + 8);
                 /* Now we expect an idstr */
                 tmp32 = buf[12]; /* Length of the following idstr */
                 buf[13 + tmp32] = '\0';
diff --git a/migration/savevm.c b/migration/savevm.c
index ae2ef8b..6da084c 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -823,9 +823,9 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
     buf[tmplen++] = '\0';
 
     for (t = 0; t < len; t++) {
-        cpu_to_be64w((uint64_t *)(buf + tmplen), start_list[t]);
+        stq_be_p(buf + tmplen, start_list[t]);
         tmplen += 8;
-        cpu_to_be64w((uint64_t *)(buf + tmplen), length_list[t]);
+        stq_be_p(buf + tmplen, length_list[t]);
         tmplen += 8;
     }
     qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_RAM_DISCARD, tmplen, buf);
-- 
2.7.4

  reply	other threads:[~2016-06-17 13:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 13:06 [Qemu-devel] [PULL 00/13] migration: many fixes Amit Shah
2016-06-17 13:06 ` Amit Shah [this message]
2016-06-17 13:06 ` [Qemu-devel] [PULL 02/13] migration: Trace improvements Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 03/13] migration: fix inability to save VM after snapshot Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 04/13] migration: Fix multi-thread compression bug Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 05/13] migration: Fix a potential issue Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 06/13] migration: remove useless code Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 07/13] qemu-file: Fix qemu_put_compression_data flaw Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 08/13] migration: refine ram_save_compressed_page Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 09/13] migration: protect the quit flag by lock Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 10/13] migration: refine the compression code Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 11/13] migration: refine the decompression code Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 12/13] migration: code clean up Amit Shah
2016-06-17 13:06 ` [Qemu-devel] [PULL 13/13] vmstate-static-checker: fix size mismatch detection in unused fields Amit Shah
2016-06-17 13:58 ` [Qemu-devel] [PULL 00/13] migration: many fixes Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d885131574ba530e48ef90d5c0ca4dffc9c3759.1466168448.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=den@openvz.org \
    --cc=dgilbert@redhat.com \
    --cc=liang.z.li@intel.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.