migration: Don't use *_to_cpup() and cpu_to_*w()

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>
This commit is contained in:
Peter Maydell 2016-06-10 17:09:22 +01:00 committed by Amit Shah
parent 4acc8fdfd3
commit 4d88513157
2 changed files with 8 additions and 8 deletions

View File

@ -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';

View File

@ -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);