[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 06/11] int128.h: Avoid undefined behaviours involvi
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 06/11] int128.h: Avoid undefined behaviours involving signed arithmetic |
Date: |
Tue, 8 Apr 2014 11:04:06 +0400 |
From: Peter Maydell <address@hidden>
Add casts when we're performing arithmetic on the .hi parts of an
Int128, to avoid undefined behaviour.
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
include/qemu/int128.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 9ed47aa..f597031 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -53,7 +53,7 @@ static inline Int128 int128_rshift(Int128 a, int n)
if (n >= 64) {
return (Int128) { h, h >> 63 };
} else {
- return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), h };
+ return (Int128) { (a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h };
}
}
@@ -78,7 +78,7 @@ static inline Int128 int128_neg(Int128 a)
static inline Int128 int128_sub(Int128 a, Int128 b)
{
- return (Int128){ a.lo - b.lo, a.hi - b.hi - (a.lo < b.lo) };
+ return (Int128){ a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo) };
}
static inline bool int128_nonneg(Int128 a)
--
1.7.10.4
- [Qemu-trivial] [PULL for-2.0 00/11] Trivial patches for 2014-04-08, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 05/11] hw/ide/ahci.c: Avoid shift left into sign bit, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 04/11] net: Report error when device / hub combo is not found., Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 01/11] vl: Report accelerator not supported for target more nicely, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 02/11] qga: trivial fix for unclear documentation of guest-set-time, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 07/11] xbzrle.c: Avoid undefined behaviour with signed arithmetic, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 06/11] int128.h: Avoid undefined behaviours involving signed arithmetic,
Michael Tokarev <=
- [Qemu-trivial] [PULL 03/11] configure: Fix indentation of help for --enable/disable-debug-info, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 09/11] configure: Remove redundant message for -Werror, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 11/11] Fix grammar in comment, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 08/11] scripts: add sample model file for Coverity Scan, Michael Tokarev, 2014/04/08
- [Qemu-trivial] [PULL 10/11] doc: grammify "allows to", Michael Tokarev, 2014/04/08
- Re: [Qemu-trivial] [Qemu-devel] [PULL for-2.0 00/11] Trivial patches for 2014-04-08, Peter Maydell, 2014/04/08