From patchwork Thu Apr 27 01:46:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9702263 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 78E5B601D3 for ; Thu, 27 Apr 2017 01:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 696A4285F8 for ; Thu, 27 Apr 2017 01:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D2E128602; Thu, 27 Apr 2017 01:51:11 +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 E15E8285F8 for ; Thu, 27 Apr 2017 01:51:10 +0000 (UTC) Received: from localhost ([::1]:57801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3YaM-0001wK-58 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Apr 2017 21:51:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3YW0-0007UA-4p for qemu-devel@nongnu.org; Wed, 26 Apr 2017 21:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3YVz-00044n-83 for qemu-devel@nongnu.org; Wed, 26 Apr 2017 21:46:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40084) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3YVw-000427-Lq; Wed, 26 Apr 2017 21:46:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9432067EA7; Thu, 27 Apr 2017 01:46:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9432067EA7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9432067EA7 Received: from red.redhat.com (ovpn-123-177.rdu2.redhat.com [10.10.123.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id D46BA18114; Thu, 27 Apr 2017 01:46:34 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 20:46:15 -0500 Message-Id: <20170427014626.11553-7-eblake@redhat.com> In-Reply-To: <20170427014626.11553-1-eblake@redhat.com> References: <20170427014626.11553-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 27 Apr 2017 01:46:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v10 06/17] qemu-io: Don't open-code QEMU_IS_ALIGNED 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: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Manual comparison against 0x1ff is not as clean as using our alignment macros from osdep.h. Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Eric Blake Reviewed-by: Max Reitz --- v10: new patch --- qemu-io-cmds.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 21af9e6..fabc394 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -740,12 +740,12 @@ static int read_f(BlockBackend *blk, int argc, char **argv) } if (bflag) { - if (offset & 0x1ff) { + if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; } - if (count & 0x1ff) { + if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { printf("count %"PRId64" is not sector aligned\n", count); return 0; @@ -1050,13 +1050,13 @@ static int write_f(BlockBackend *blk, int argc, char **argv) } if (bflag || cflag) { - if (offset & 0x1ff) { + if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; } - if (count & 0x1ff) { + if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) { printf("count %"PRId64" is not sector aligned\n", count); return 0; @@ -1769,7 +1769,7 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv) if (offset < 0) { print_cvtnum_err(offset, argv[1]); return 0; - } else if (offset & 0x1ff) { + } else if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0;