* [Qemu-devel] [PATCH] Fix integer overflow in block migration bandwidth calculation
@ 2011-03-31 13:52 Avishay Traeger
2011-04-05 12:54 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Avishay Traeger @ 2011-03-31 13:52 UTC (permalink / raw)
To: qemu-devel; +Cc: Liran Schour
block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a
negative number, resulting in a negative bandwidth (running on a 32-bit
machine). Cast to avoid.
Signed-off-by: Avishay Traeger <avishay@il.ibm.com>
---
block-migration.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/block-migration.c b/block-migration.c
index 8218bac..ffc92ee 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time)
static inline long double compute_read_bwidth(void)
{
assert(block_mig_state.total_time != 0);
- return (block_mig_state.reads * BLOCK_SIZE)/
block_mig_state.total_time;
+ return ((long long)block_mig_state.reads * BLOCK_SIZE)/
block_mig_state.total_time;
}
static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix integer overflow in block migration bandwidth calculation
2011-03-31 13:52 [Qemu-devel] [PATCH] Fix integer overflow in block migration bandwidth calculation Avishay Traeger
@ 2011-04-05 12:54 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2011-04-05 12:54 UTC (permalink / raw)
To: Avishay Traeger; +Cc: qemu-devel, Liran Schour
Am 31.03.2011 15:52, schrieb Avishay Traeger:
>
> block_mig_state.reads is an int, and multiplying by BLOCK_SIZE yielded a
> negative number, resulting in a negative bandwidth (running on a 32-bit
> machine). Cast to avoid.
>
> Signed-off-by: Avishay Traeger <avishay@il.ibm.com>
This patch is corrupted by line wraps.
> ---
> block-migration.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/block-migration.c b/block-migration.c
> index 8218bac..ffc92ee 100644
> --- a/block-migration.c
> +++ b/block-migration.c
> @@ -140,7 +140,7 @@ static inline void add_avg_read_time(int64_t time)
> static inline long double compute_read_bwidth(void)
> {
> assert(block_mig_state.total_time != 0);
> - return (block_mig_state.reads * BLOCK_SIZE)/
> block_mig_state.total_time;
> + return ((long long)block_mig_state.reads * BLOCK_SIZE)/
> block_mig_state.total_time;
This line exceeds 80 characters. While you're at it, you could add a
space before the /
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-05 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-31 13:52 [Qemu-devel] [PATCH] Fix integer overflow in block migration bandwidth calculation Avishay Traeger
2011-04-05 12:54 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).