util/romcc: avoid shifting more than the variable's width

That's undefined behavior in C

Change-Id: I671ed8abf02e57a7cc993d1a85354e905f51717d
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Found-by: Coverity Scan #1229557
Reviewed-on: https://review.coreboot.org/18014
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Georgi 2017-01-02 18:47:50 +01:00 committed by Martin Roth
parent 6d0c65ebc6
commit 766c3fec2d
1 changed files with 2 additions and 2 deletions

View File

@ -10021,13 +10021,13 @@ static void simplify_copy(struct compile_state *state, struct triple *ins)
/* Ensure I am properly sign extended */
if (size_of(state, right->type) < size_of(state, ins->type) &&
is_signed(right->type)) {
long_t val;
uint64_t val;
int shift;
shift = SIZEOF_LONG - size_of(state, right->type);
val = left;
val <<= shift;
val >>= shift;
left = val;
left = (ulong_t)val;
}
mkconst(state, ins, left);
break;