A problem with the existing code was that struct expr::byteorder was not updated despite the call to mpz_switch_byteorder(). Doing so leads to an extra byteorder swap during data linearization though, so in order to have byteorder swapped *and* the field value set correctly, simply update the latter and rely upon the implicitly happening conversion. Signed-off-by: Phil Sutter --- src/intervals.c | 10 +++------- src/netlink.c | 5 ++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/intervals.c b/src/intervals.c index 438957c52d391..6a917b7b79c3f 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -793,11 +793,8 @@ int setelem_to_interval(const struct set *set, struct expr *elem, } low = constant_expr_alloc(&key->location, set->key->dtype, - set->key->byteorder, set->key->len, NULL); - + BYTEORDER_BIG_ENDIAN, set->key->len, NULL); mpz_set(low->value, key->range.low); - if (set->key->byteorder == BYTEORDER_HOST_ENDIAN) - mpz_switch_byteorder(low->value, set->key->len / BITS_PER_BYTE); low = set_elem_expr_alloc(&key->location, low); set_elem_expr_copy(low, interval_expr_key(elem)); @@ -819,12 +816,11 @@ int setelem_to_interval(const struct set *set, struct expr *elem, } high = constant_expr_alloc(&key->location, set->key->dtype, - set->key->byteorder, set->key->len, + BYTEORDER_BIG_ENDIAN, set->key->len, NULL); mpz_set(high->value, key->range.high); mpz_add_ui(high->value, high->value, 1); - if (set->key->byteorder == BYTEORDER_HOST_ENDIAN) - mpz_switch_byteorder(high->value, set->key->len / BITS_PER_BYTE); + high->byteorder = BYTEORDER_BIG_ENDIAN; high = set_elem_expr_alloc(&key->location, high); diff --git a/src/netlink.c b/src/netlink.c index 2a6caa9c76565..3228747a74af8 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -323,9 +323,8 @@ static int __netlink_gen_concat_key(uint32_t flags, const struct expr *i, break; expr = (struct expr *)i; - if (expr_basetype(expr)->type == TYPE_INTEGER && - expr->byteorder == BYTEORDER_HOST_ENDIAN) - byteorder_switch_expr_value(value, expr); + if (expr_basetype(expr)->type == TYPE_INTEGER) + expr->byteorder = BYTEORDER_BIG_ENDIAN; break; default: BUG("invalid expression type '%s' in set", expr_ops(i)->name); -- 2.51.0