From patchwork Fri Jun 17 13:06:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 70320 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp273961qgy; Fri, 17 Jun 2016 06:13:36 -0700 (PDT) X-Received: by 10.55.47.6 with SMTP id v6mr2105996qkh.11.1466169216706; Fri, 17 Jun 2016 06:13:36 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k17si31398398qkl.124.2016.06.17.06.13.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 17 Jun 2016 06:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:57387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtaa-0005R4-88 for patch@linaro.org; Fri, 17 Jun 2016 09:13:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtUK-0007Jf-4v for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDtUF-000830-25 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtUE-00082p-QG for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:07:02 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 45250C04B311; Fri, 17 Jun 2016 13:07:02 +0000 (UTC) Received: from localhost (ovpn-116-17.sin2.redhat.com [10.67.116.17]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5HD70CI027342; Fri, 17 Jun 2016 09:07:01 -0400 From: Amit Shah To: Peter Maydell Date: Fri, 17 Jun 2016 18:36:40 +0530 Message-Id: <4d885131574ba530e48ef90d5c0ca4dffc9c3759.1466168448.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Jun 2016 13:07:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/13] migration: Don't use *_to_cpup() and cpu_to_*w() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , liang.z.li@intel.com, qemu list , "Dr. David Alan Gilbert" , Amit Shah , den@openvz.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Reviewed-by: Eric Blake Reviewed-by: Amit Shah Message-Id: <1465574962-2710-1-git-send-email-peter.maydell@linaro.org> Signed-off-by: Amit Shah --- migration/migration.c | 12 ++++++------ migration/savevm.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) -- 2.7.4 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);