From patchwork Tue Aug 27 18:59:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 11117385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D271614DB for ; Tue, 27 Aug 2019 19:01:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD1C721881 for ; Tue, 27 Aug 2019 19:01:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b/YLMTPI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD1C721881 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2gix-0001bn-Ak for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 15:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33894) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2ggf-0008Me-QW for qemu-devel@nongnu.org; Tue, 27 Aug 2019 14:59:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2gge-0006Nx-Dt for qemu-devel@nongnu.org; Tue, 27 Aug 2019 14:59:25 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35071) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2gge-0006NX-3x; Tue, 27 Aug 2019 14:59:24 -0400 Received: by mail-wm1-x343.google.com with SMTP id l2so210042wmg.0; Tue, 27 Aug 2019 11:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WHUo3Tga0CGNATwCAfQwI44kWXDmXDYMUfkHqnRgu3E=; b=b/YLMTPITid9bZP3cnOmIU6dozatrMb5vF2Rnzjz18yea61NNujUhqfJbs4zCjHJgN zW8qOZKm/E2bjW5ipGrRBxOC9nM0ArEClf34W9F2/06UJVk3zYWQw01CseKk1PaHYSw/ TXlfASWG4E48h7hT32o1IBunP2ioj+p/Y3YN47OK4AlnVxjU97IAhSz4+pjfNRrqDpZ2 NHH9eC99E6IfBE2V/kgUBaICVdkfp/HYYBNVhh1920FbYfyuxBd0fAqpLGNc+q7S9KvF YMy+TsP67lGCEBQrZ4h+zR+EFVeJP5N9icbNKWICY3ea0HHNAMVqdZPfAzMka9yC/bHM Qmxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WHUo3Tga0CGNATwCAfQwI44kWXDmXDYMUfkHqnRgu3E=; b=op26fAtjsmrei4liob+DCOdJiWURDHqNHHbeNwpH9MZctjhrZrb3rMh02yrUjrpUht nXQsTAXW2xxrGFMcMeTP65CmnZDpxBEdvcjZqVu+I8PN8WOy2lCive0CHdvLY98jvxIL aWkwE7ghnADNz0WQOphaUvNts1vy6gSlauMSUWsh1vvrBiAEP5Pe6DxixPxwtkFU/jZH cahL0XgRjhGizJdIAAuNlJONTiCqv86Xlm8bALbswNFCyz6anZxv2m/hnUn+XquJh+S4 jE7xDScVIfEIvS4GedeO0GmwmXc5mJ/qhYBgvuPyax66+JNLJ4Vh0WeOOzvQxOKlAm0v uu0g== X-Gm-Message-State: APjAAAXUTG5BJyJzu3uUP22LY0Ziot1/I/s5xys4AraNagSJyA77ycB7 VnOoLe/oNA+f/Jt4oyLWZuxRbB/O9DAiRw== X-Google-Smtp-Source: APXvYqwTTHq+2vwLFuj9TSBLQ1uHBO+hNP4DGmDTlIdX1MOCww1P7ZXLM2T6qwcFER+m2x7QnDVEFw== X-Received: by 2002:a1c:c018:: with SMTP id q24mr7481wmf.162.1566932359123; Tue, 27 Aug 2019 11:59:19 -0700 (PDT) Received: from localhost.localdomain (109-186-142-128.bb.netvision.net.il. [109.186.142.128]) by smtp.gmail.com with ESMTPSA id g26sm9926wmh.32.2019.08.27.11.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 11:59:18 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2019 21:59:12 +0300 Message-Id: <20190827185913.27427-2-nsoffer@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190827185913.27427-1-nsoffer@redhat.com> References: <20190827185913.27427-1-nsoffer@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v2 1/2] block: Use QEMU_IS_ALIGNED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Max Reitz , Nir Soffer , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace instances of: (n & (BDRV_SECTOR_SIZE - 1)) == 0 And: (n & ~BDRV_SECTOR_MASK) == 0 With: QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE) Which reveals the intent of the code better, and makes it easier to locate the code checking alignment. Signed-off-by: Nir Soffer --- block/bochs.c | 4 ++-- block/cloop.c | 4 ++-- block/dmg.c | 4 ++-- block/io.c | 8 ++++---- block/qcow2-cluster.c | 4 ++-- block/qcow2.c | 4 ++-- block/vvfat.c | 8 ++++---- qemu-img.c | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/block/bochs.c b/block/bochs.c index 962f18592d..32bb83b268 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -248,8 +248,8 @@ bochs_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector local_qiov; int ret; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); qemu_iovec_init(&local_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); diff --git a/block/cloop.c b/block/cloop.c index 384c9735bb..4de94876d4 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -253,8 +253,8 @@ cloop_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int nb_sectors = bytes >> BDRV_SECTOR_BITS; int ret, i; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); qemu_co_mutex_lock(&s->lock); diff --git a/block/dmg.c b/block/dmg.c index 45f6b28f17..4a045f2b3e 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -697,8 +697,8 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int nb_sectors = bytes >> BDRV_SECTOR_BITS; int ret, i; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); qemu_co_mutex_lock(&s->lock); diff --git a/block/io.c b/block/io.c index 56bbf195bb..7508703ecd 100644 --- a/block/io.c +++ b/block/io.c @@ -1080,8 +1080,8 @@ static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs, sector_num = offset >> BDRV_SECTOR_BITS; nb_sectors = bytes >> BDRV_SECTOR_BITS; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); assert(bytes <= BDRV_REQUEST_MAX_BYTES); assert(drv->bdrv_co_readv); @@ -1133,8 +1133,8 @@ static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs, sector_num = offset >> BDRV_SECTOR_BITS; nb_sectors = bytes >> BDRV_SECTOR_BITS; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); assert(bytes <= BDRV_REQUEST_MAX_BYTES); assert(drv->bdrv_co_writev); diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index cc5609e27a..f2de74690d 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -470,8 +470,8 @@ static bool coroutine_fn do_perform_cow_encrypt(BlockDriverState *bs, { if (bytes && bs->encrypted) { BDRVQcow2State *s = bs->opaque; - assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0); - assert((bytes & ~BDRV_SECTOR_MASK) == 0); + assert(QEMU_IS_ALIGNED(offset_in_cluster, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); assert(s->crypto); if (qcow2_co_encrypt(bs, cluster_offset, src_cluster_offset + offset_in_cluster, diff --git a/block/qcow2.c b/block/qcow2.c index 7c5a4859f7..e82961c9cf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2072,8 +2072,8 @@ static coroutine_fn int qcow2_co_preadv(BlockDriverState *bs, uint64_t offset, } if (bs->encrypted) { assert(s->crypto); - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(cur_bytes, BDRV_SECTOR_SIZE)); if (qcow2_co_decrypt(bs, cluster_offset, offset, cluster_data, cur_bytes) < 0) { ret = -EIO; diff --git a/block/vvfat.c b/block/vvfat.c index f6c28805dd..019b8f1341 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1547,8 +1547,8 @@ vvfat_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int nb_sectors = bytes >> BDRV_SECTOR_BITS; void *buf; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); buf = g_try_malloc(bytes); if (bytes && buf == NULL) { @@ -3082,8 +3082,8 @@ vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int nb_sectors = bytes >> BDRV_SECTOR_BITS; void *buf; - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0); + assert(QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)); + assert(QEMU_IS_ALIGNED(bytes, BDRV_SECTOR_SIZE)); buf = g_try_malloc(bytes); if (bytes && buf == NULL) { diff --git a/qemu-img.c b/qemu-img.c index 7daa05e51a..cff21facf0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2141,7 +2141,7 @@ static int img_convert(int argc, char **argv) int64_t sval; sval = cvtnum(optarg); - if (sval < 0 || sval & (BDRV_SECTOR_SIZE - 1) || + if (sval < 0 || !QEMU_IS_ALIGNED(sval, BDRV_SECTOR_SIZE) || sval / BDRV_SECTOR_SIZE > MAX_BUF_SECTORS) { error_report("Invalid buffer size for sparse output specified. " "Valid sizes are multiples of %llu up to %llu. Select " From patchwork Tue Aug 27 18:59:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 11117383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C2E414DB for ; Tue, 27 Aug 2019 19:01:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3674921881 for ; Tue, 27 Aug 2019 19:01:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LhU/QzLQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3674921881 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2gix-0001aq-1m for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Aug 2019 15:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2ggd-0008Kl-V0 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 14:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2ggc-0006NL-OK for qemu-devel@nongnu.org; Tue, 27 Aug 2019 14:59:23 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2ggc-0006Mq-HK; Tue, 27 Aug 2019 14:59:22 -0400 Received: by mail-wr1-x444.google.com with SMTP id e16so2768733wro.5; Tue, 27 Aug 2019 11:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5WYteARbw4F5SMsy3ezROwY8/lmuvqrn3c2e82dR+CI=; b=LhU/QzLQDQJPOddPNAx507pS8CqPjDObAoivk4qQmawxg80NZUpd0QodcwNzwkBU7w 7Pk7xlDiu0lH2WMVyXDcsTZChJJNnr+hA+WRL9A98Fl1z61vcxJKQjnTD3YkdTjlTKae t2WLbcDkGzxVDO83xGsSFRI/9NVYPmP8jotf+n5V2Bklp2g2ydYQWqiWHZcvTYUZpXxg iDbjgGx1cMIzGU3xDhT6ZlYsqtpshiFNBAaF8wQcCsNxn+EKViaT0UDlhZnuP2NBsWPg H/gRULi18Cczx4LmzN5ngtjkxVupc6hgqYXIfpbm0tao57qmfV8uSoLHLGyJe7IP0jyS cJ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5WYteARbw4F5SMsy3ezROwY8/lmuvqrn3c2e82dR+CI=; b=uQUES4srtRUJKZrTUUsyYjKoxhZwS7ag9N8aUyEK15iBVZ8c1QA7NzjmSUXUSH97/d lP+QKVRkrwkU2HxinOfigQipFJvCQPKOw/zMcPpYyrkz5+sJ0psNrS2hv9aqReGiewWA aqOSR9ms/B3kJmhFLvXVbcfx5GCXCNzL15nZXrUiunwO704OwVkznimAKrp2CuaaeYWt ZHR+PEJs89PsrlueT9oyvxE23219ICUlaI0KH8hy2m0x7chmxqZ5gcqIeAvA9QSVItYD 7AD+UEB31qp2Gj97us9TEO1wUjBuZT41P4IjKDlFKl6CwJwByMlQNs9ksCWRlV6xaoSc MbCg== X-Gm-Message-State: APjAAAVrZ1iGGc4OfMxYRMe936eis6BUbcutd84nE+D5MguzDugXCphu XJQSgIsauPtq6MifP2ngqpOSXw6LnPXWEQ== X-Google-Smtp-Source: APXvYqxagZS3jZc/wJugW9RjPGZP+DNUcsuwLNApbRn7tzxMqzGP4AhTsnXh4mZN/jjZwgGJuBZjuQ== X-Received: by 2002:a5d:6a05:: with SMTP id m5mr32331916wru.305.1566932361121; Tue, 27 Aug 2019 11:59:21 -0700 (PDT) Received: from localhost.localdomain (109-186-142-128.bb.netvision.net.il. [109.186.142.128]) by smtp.gmail.com with ESMTPSA id g26sm9926wmh.32.2019.08.27.11.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 11:59:20 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: qemu-devel@nongnu.org Date: Tue, 27 Aug 2019 21:59:13 +0300 Message-Id: <20190827185913.27427-3-nsoffer@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190827185913.27427-1-nsoffer@redhat.com> References: <20190827185913.27427-1-nsoffer@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v2 2/2] block: Remove unused masks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Max Reitz , Nir Soffer , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Replace confusing usage: ~BDRV_SECTOR_MASK With more clear: (BDRV_SECTOR_SIZE - 1) Remove BDRV_SECTOR_MASK and the unused BDRV_BLOCK_OFFSET_MASK which was it's last user. Signed-off-by: Nir Soffer Reviewed-by: Juan Quintela Reviewed-by: John Snow --- include/block/block.h | 2 -- migration/block.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 124ad40809..37c9de7446 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -143,7 +143,6 @@ typedef struct HDGeometry { #define BDRV_SECTOR_BITS 9 #define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS) -#define BDRV_SECTOR_MASK ~(BDRV_SECTOR_SIZE - 1) #define BDRV_REQUEST_MAX_SECTORS MIN(SIZE_MAX >> BDRV_SECTOR_BITS, \ INT_MAX >> BDRV_SECTOR_BITS) @@ -195,7 +194,6 @@ typedef struct HDGeometry { #define BDRV_BLOCK_ALLOCATED 0x10 #define BDRV_BLOCK_EOF 0x20 #define BDRV_BLOCK_RECURSE 0x40 -#define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; diff --git a/migration/block.c b/migration/block.c index aa747b55fa..92c36b68ec 100644 --- a/migration/block.c +++ b/migration/block.c @@ -906,7 +906,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) do { addr = qemu_get_be64(f); - flags = addr & ~BDRV_SECTOR_MASK; + flags = addr & (BDRV_SECTOR_SIZE - 1); addr >>= BDRV_SECTOR_BITS; if (flags & BLK_MIG_FLAG_DEVICE_BLOCK) {