ForCES: Fix undefined behaviour in op_valid().

[print-forces.c:316] -> [print-forces.c:323]: (warning) Shifting 32-bit
value by 32767 bits is undefined behaviour. See condition at line 323.
[print-forces.c:316]: (error) Shifting by a negative value is undefined
behaviour
This commit is contained in:
Denis Ovsienko 2017-09-06 00:34:33 +01:00
parent 2dfa645e86
commit eb02553274

View File

@ -313,12 +313,10 @@ static inline char *indent_pr(int indent, int nlpref)
static inline int op_valid(uint16_t op, uint16_t mask)
{
int opb = 1 << (op - 1);
if (op == 0)
return 0;
if (opb & mask)
return 1;
if (op <= F_OP_MAX)
return (1 << (op - 1)) & mask; /* works only for 0x0001 through 0x0010 */
/* I guess we should allow vendor operations? */
if (op >= 0x8000)
return 1;