yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-Don-t-call-ROUND_UP-with-negative-values.patch

9ae3a8
From d133282ff639fd022fe64172f89b203cf8669114 Mon Sep 17 00:00:00 2001
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Date: Fri, 7 Feb 2014 16:00:09 +0100
9ae3a8
Subject: [PATCH 37/37] block: Don't call ROUND_UP with negative values
9ae3a8
9ae3a8
Message-id: <1392117622-28812-37-git-send-email-kwolf@redhat.com>
9ae3a8
Patchwork-id: 57201
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 37/37] block: Don't call ROUND_UP with negative values
9ae3a8
Bugzilla: 748906
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
The behaviour of the ROUND_UP macro with negative numbers isn't obvious.
9ae3a8
It happens to do the right thing in this please, but better avoid it.
9ae3a8
9ae3a8
Suggested-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
---
9ae3a8
 block.c | 4 ++--
9ae3a8
 1 file changed, 2 insertions(+), 2 deletions(-)
9ae3a8
---
9ae3a8
 block.c |    4 ++--
9ae3a8
 1 files changed, 2 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/block.c b/block.c
9ae3a8
index b878c8b..1b57236 100644
9ae3a8
--- a/block.c
9ae3a8
+++ b/block.c
9ae3a8
@@ -2760,8 +2760,8 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
9ae3a8
         }
9ae3a8
 
9ae3a8
         total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
9ae3a8
-        max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num,
9ae3a8
-                                         align >> BDRV_SECTOR_BITS));
9ae3a8
+        max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num),
9ae3a8
+                                  align >> BDRV_SECTOR_BITS);
9ae3a8
         if (max_nb_sectors > 0) {
9ae3a8
             ret = drv->bdrv_co_readv(bs, sector_num,
9ae3a8
                                      MIN(nb_sectors, max_nb_sectors), qiov);
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8