evaluate: zap useless 0-shifts
Florian Westphal
maintainerPATCH 1/1 evaluate: zap useless 0-shifts
There is a (not yet applied) kernel patch that rejects 0-shifts, auto-suppress them at eval stage.
Signed-off-by Florian Westphal <[email protected]>
--- src/evaluate.c | 6 ++++++ 1 file changed, 6 insertions(+)
src/evaluate.c +6 -0
@@ -1454,6 +1454,12 @@ static int expr_evaluate_shift(struct eval_ctx *ctx, struct expr **expr) "shifts exceeding %u bits are not supported", UINT_MAX); shift =mpz_get_uint32 (right->value); +if (shift ==0 ) { + *expr =expr_get (left); +expr_free (op); +return 0 ; + } +if (ctx->stmt_len > left->len) max_shift_len = ctx->stmt_len;else
Signature · 1 line
2.53.0
Quoted 5 lines · Florian Westphal
There is a (not yet applied) kernel patch that rejects 0-shifts, auto-suppress them at eval stage.
Signed-off-by Florian Westphal <[email protected]>---
Reviewed-by Fernando Fernandez Mancera <[email protected]>
That is quite elegant indeed, thanks!
Quoted 20 lines
src/evaluate.c | 6 ++++++ 1 file changed, 6 insertions(+)src/evaluate.c +6
-0@@ -1454,6 +1454,12 @@ static int expr_evaluate_shift(struct eval_ctx *ctx, struct expr **expr) "shifts exceeding %u bits are not supported", UINT_MAX); shift =mpz_get_uint32 (right->value); +if (shift ==0 ) { + *expr =expr_get (left); +expr_free (op); +return 0 ; + } +if (ctx->stmt_len > left->len) max_shift_len = ctx->stmt_len;else