From patchwork Fri Jun 10 15:01:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9169985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE4EB607D9 for ; Fri, 10 Jun 2016 15:01:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0D4C28325 for ; Fri, 10 Jun 2016 15:01:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 957B528368; Fri, 10 Jun 2016 15:01:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B53A28325 for ; Fri, 10 Jun 2016 15:01:44 +0000 (UTC) Received: from localhost ([::1]:41778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNwN-00025I-9l for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Jun 2016 11:01:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNvx-000240-JB for qemu-devel@nongnu.org; Fri, 10 Jun 2016 11:01:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBNvu-0006Tz-61 for qemu-devel@nongnu.org; Fri, 10 Jun 2016 11:01:15 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNvt-0006Th-V3 for qemu-devel@nongnu.org; Fri, 10 Jun 2016 11:01:14 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bBNvt-0002Bf-A8; Fri, 10 Jun 2016 16:01:13 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 10 Jun 2016 16:01:12 +0100 Message-Id: <1465570872-23642-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] migration: Don't use *_to_cpup() 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: Amit Shah , Juan Quintela , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The *_to_cpup() functions just compose a pointer dereference with a *_to_cpu() byteswap. Instead use ld*_p(), which handles potential pointer misaligment and avoids the need to cast the pointer. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake --- The motivation here is that I'd like to get rid of _to_cpup() entirely: we don't have many places that use it. --- migration/migration.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 7ecbade..551da0a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1381,7 +1381,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); @@ -1395,13 +1395,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; @@ -1409,8 +1409,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';