On 2020-02-29, at 11:27:18 +0000, Jeremy Sowden wrote: > Endianness is not meaningful for objects smaller than 2 bytes and the > byte-order conversions are no-ops in the kernel, so don't bother > inserting them. > > Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> > --- > src/evaluate.c | 2 +- > tests/py/any/meta.t.payload | 4 ---- > 2 files changed, 1 insertion(+), 5 deletions(-) > > diff --git a/src/evaluate.c b/src/evaluate.c > index 9b1a04f26f44..d5cc386d9792 100644 > --- a/src/evaluate.c > +++ b/src/evaluate.c > @@ -149,7 +149,7 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr, > > if (expr_is_constant(*expr)) > (*expr)->byteorder = byteorder; > - else { > + else if ((*expr)->len / BITS_PER_BYTE > 1) { > op = byteorder_conversion_op(*expr, byteorder); > *expr = unary_expr_alloc(&(*expr)->location, op, *expr); > if (expr_evaluate(ctx, expr) < 0) This isn't quite right. It should be: @@ -147,7 +147,7 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr, byteorder_names[byteorder], byteorder_names[(*expr)->byteorder]); - if (expr_is_constant(*expr)) + if (expr_is_constant(*expr) || (*expr)->len / BITS_PER_BYTE < 2) (*expr)->byteorder = byteorder; else { op = byteorder_conversion_op(*expr, byteorder); I'll send out a new version this evening.
Attachment:
signature.asc
Description: PGP signature