From patchwork Thu Jun 16 14:16:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9181233 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 7B34C60776 for ; Thu, 16 Jun 2016 15:08:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2CD27248 for ; Thu, 16 Jun 2016 15:08:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6116D28383; Thu, 16 Jun 2016 15:08:12 +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 205FD28365 for ; Thu, 16 Jun 2016 15:08:09 +0000 (UTC) Received: from localhost ([::1]:49944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDYts-0007av-24 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Jun 2016 11:08:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDY6D-0006rT-Fz for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:16:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDY68-00031D-7U for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:16:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDY68-000315-1Y for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:16:44 -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 B23F280099; Thu, 16 Jun 2016 14:16:43 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-58.ams2.redhat.com [10.36.112.58]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5GEGQgj016497; Thu, 16 Jun 2016 10:16:42 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 16 Jun 2016 16:16:05 +0200 Message-Id: <1466086585-16526-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1466086585-16526-1-git-send-email-pbonzini@redhat.com> References: <1466086585-16526-1-git-send-email-pbonzini@redhat.com> 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.28]); Thu, 16 Jun 2016 14:16:43 +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 10/30] nbd: Don't use cpu_to_*w() functions 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell 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 Message-Id: <1465575342-12146-1-git-send-email-peter.maydell@linaro.org> Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- nbd/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index bb8981f..6d9c74d 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -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) {