mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: util/romcc: avoid shifting more than the variable's width
That's undefined behavior in C Change-Id: I671ed8abf02e57a7cc993d1a85354e905f51717d Original-Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Found-by: Coverity Scan #1229557 Original-Reviewed-on: https://review.coreboot.org/18014 Original-Tested-by: build bot (Jenkins) Original-Reviewed-by: Martin Roth <martinroth@google.com> Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425983 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
This commit is contained in:
parent
4795dcf9f2
commit
c1e1da8f10
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue