projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
PR26449, PR26450 UBSAN: frv-ibld.c:135 left shift
[deliverable/binutils-gdb.git]
/
opcodes
/
lm32-ibld.c
diff --git
a/opcodes/lm32-ibld.c
b/opcodes/lm32-ibld.c
index 2b0efdaa3f73521b698d9eb48e45e78a2e0b11ac..48e894a9ee1297d0fc0e0281d6feb5d143717220 100644
(file)
--- a/
opcodes/lm32-ibld.c
+++ b/
opcodes/lm32-ibld.c
@@
-85,13
+85,13
@@
insert_1 (CGEN_CPU_DESC cd,
int word_length,
unsigned char *bufp)
{
int word_length,
unsigned char *bufp)
{
- unsigned long x,mask;
+ unsigned long x,
mask;
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
int shift;
x = cgen_get_insn_value (cd, bufp, word_length, cd->endian);
/* Written this way to avoid undefined behaviour. */
- mask = (
((1L << (length - 1)) - 1) << 1) |
1;
+ mask = (
1UL << (length - 1) << 1) -
1;
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
if (CGEN_INSN_LSB0_P)
shift = (start + 1) - length;
else
@@
-131,13
+131,15
@@
insert_normal (CGEN_CPU_DESC cd,
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
CGEN_INSN_BYTES_PTR buffer)
{
static char errbuf[100];
- /* Written this way to avoid undefined behaviour. */
- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
+ unsigned long mask;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
/* If LENGTH is zero, this operand doesn't contribute to the value. */
if (length == 0)
return NULL;
+ /* Written this way to avoid undefined behaviour. */
+ mask = (1UL << (length - 1) << 1) - 1;
+
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
if (word_length > 8 * sizeof (CGEN_INSN_INT))
abort ();
@@
-314,7
+316,7
@@
put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
{
int shift = insn_length - length;
/* Written this way to avoid undefined behaviour. */
- CGEN_INSN_INT mask =
(((1L << (length - 1)) - 1) << 1) |
1;
+ CGEN_INSN_INT mask =
length == 0 ? 0 : (1UL << (length - 1) << 1) -
1;
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
*buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
}
@@
-491,7
+493,7
@@
extract_normal (CGEN_CPU_DESC cd,
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
#endif /* ! CGEN_INT_INSN_P */
/* Written this way to avoid undefined behaviour. */
- mask = (
((1L << (length - 1)) - 1) << 1) |
1;
+ mask = (
1UL << (length - 1) << 1) -
1;
value &= mask;
/* sign extend? */
value &= mask;
/* sign extend? */
This page took
0.032158 seconds
and
4
git commands to generate.