summaryrefslogtreecommitdiff
path: root/hw/ide
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-10-16 17:19:35 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-10-18 11:00:40 +0100
commit40fe17bea478793fc9106a630fa3610dad51f939 (patch)
treef5d8aeaff4836df6fcb3528f866bf25608d83eba /hw/ide
parentc737c7a608f4cd2c06e6600303845c4b469822c5 (diff)
downloadqemu-40fe17bea478793fc9106a630fa3610dad51f939.tar.gz
hw/ide/ahci.c: Fix shift left into sign bit
Avoid undefined behaviour from shifting left into the sign bit: hw/ide/ahci.c:551:36: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' (Unfortunately C's promotion rules mean that in the expression "some_uint8_t_variable << 24" the LHS gets promoted to signed int before shifting.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'hw/ide')
-rw-r--r--hw/ide/ahci.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 796be15635..21f76ed86e 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -548,7 +548,7 @@ static void ahci_init_d2h(AHCIDevice *ad)
ad->init_d2h_sent = true;
/* We're emulating receiving the first Reg H2D Fis from the device;
* Update the SIG register, but otherwise proceed as normal. */
- pr->sig = (ide_state->hcyl << 24) |
+ pr->sig = ((uint32_t)ide_state->hcyl << 24) |
(ide_state->lcyl << 16) |
(ide_state->sector << 8) |
(ide_state->nsector & 0xFF);