From: Florian Krohm Date: Mon, 22 Jun 2015 11:53:48 +0000 (+0000) Subject: Fix a few undefined shift operations as spotted by ubsan. X-Git-Tag: svn/VALGRIND_3_11_0^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e2f0cef0467266621602bc5353c379b19f2937b;p=thirdparty%2Fvalgrind.git Fix a few undefined shift operations as spotted by ubsan. git-svn-id: svn://svn.valgrind.org/vex/trunk@3155 --- diff --git a/VEX/priv/host_ppc_isel.c b/VEX/priv/host_ppc_isel.c index 40fe8951e0..aae7754f34 100644 --- a/VEX/priv/host_ppc_isel.c +++ b/VEX/priv/host_ppc_isel.c @@ -2475,19 +2475,21 @@ static HReg iselWordExpr_R_wrk ( ISelEnv* env, IRExpr* e, static Bool uInt_fits_in_16_bits ( UInt u ) { /* Is u the same as the sign-extend of its lower 16 bits? */ - Int i = u & 0xFFFF; - i <<= 16; - i >>= 16; - return toBool(u == (UInt)i); + UInt v = u & 0xFFFF; + + v = (Int)(v << 16) >> 16; /* sign extend */ + + return u == v; } static Bool uLong_fits_in_16_bits ( ULong u ) { /* Is u the same as the sign-extend of its lower 16 bits? */ - Long i = u & 0xFFFFULL; - i <<= 48; - i >>= 48; - return toBool(u == (ULong)i); + ULong v = u & 0xFFFFULL; + + v = (Long)(v << 48) >> 48; /* sign extend */ + + return u == v; } static Bool uLong_is_4_aligned ( ULong u ) diff --git a/VEX/priv/host_tilegx_isel.c b/VEX/priv/host_tilegx_isel.c index 7e4e6eb45f..47c7da68b1 100644 --- a/VEX/priv/host_tilegx_isel.c +++ b/VEX/priv/host_tilegx_isel.c @@ -369,12 +369,13 @@ static void doHelperCall ( ISelEnv * env, IRExpr * guard, IRCallee * cee, result. The expression may only be a word-size one. */ -static Bool uInt_fits_in_16_bits ( UInt u ) +static Bool uInt_fits_in_16_bits ( UInt u ) { - Int i = u & 0xFFFF; - i <<= 16; - i >>= 16; - return toBool(u == (UInt) i); + UInt v = u & 0xFFFF; + + v = (Int)(v << 16) >> 16; /* sign extend */ + + return u == v; } static Bool sane_AMode ( ISelEnv * env, TILEGXAMode * am )