From 347d3f3510c93321b13d269a8633057e8bfa9661 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 29 Apr 2013 21:24:51 +0200 Subject: [PATCH] Fix xdump trade column type on big endian hosts Broken in commit 14ea670 (v4.3.8), which changed struct trdstr member trd_type from char to short, but neglected to update the ca_type in trade_ca[]. On little endian hosts, the selector reads the least significant byte, with sign extension. Happens to work, because the type values are all sufficiently small integers. On big endian hosts, the selector reads the most signiciant byte, which is always zero (EF_SECTOR). Messes up xdump trade badly. --- src/lib/common/nsc.c | 2 +- tests/smoke/smoke.out | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index c3c643565..0178e822c 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -523,7 +523,7 @@ struct castr trade_ca[] = { {"timestamp", fldoff(trd_timestamp), NSC_TIME, 0, NULL, EF_BAD, NSC_EXTRA}, {"owner", fldoff(trd_owner), NSC_NATID, 0, NULL, EF_NATION, 0}, - {"type", fldoff(trd_type), NSC_CHAR, 0, NULL, EF_TABLE, 0}, + {"type", fldoff(trd_type), NSC_SHORT, 0, NULL, EF_TABLE, 0}, /* unitid's ca_table given by type, but can't express that: */ {"unitid", fldoff(trd_unitid), NSC_INT, 0, NULL, EF_BAD, 0}, {"price", fldoff(trd_price), NSC_INT, 0, NULL, EF_BAD, 0}, diff --git a/tests/smoke/smoke.out b/tests/smoke/smoke.out index d6a246738..d1df77f86 100644 --- a/tests/smoke/smoke.out +++ b/tests/smoke/smoke.out @@ -240,7 +240,7 @@ Player 00 Turn 00 starting [0:640] Command : XDUMP meta trade 0 "uid" 8 0 0 7 "owner" 5 0 0 9 -"type" 4 0 0 27 +"type" 6 0 0 27 "unitid" 8 0 0 -1 "price" 8 0 0 -1 "maxbidder" 8 0 0 9 @@ -1161,7 +1161,7 @@ CENSUS del dst [0:636] Command : XDUMP meta trade 0 "uid" 8 0 0 7 "owner" 5 0 0 9 -"type" 4 0 0 27 +"type" 6 0 0 27 "unitid" 8 0 0 -1 "price" 8 0 0 -1 "maxbidder" 8 0 0 9 -- 2.43.0