setexpr: Add explicit support for 32- and 64-bit ints

At present this function assumes that a size of 4 refers to a ulong. This
is true on 32-bit machines but not commonly on 64-bit machines.

This means that the 'l' specify does not work correctly with setexpr.

Add an explicit case for 32-bit values so that 64-bit machines can still
use the 'l' specifier. On 32-bit machines, 64-bit is still not supported.

This corrects the operation of the default size (which is 4 for setexpr),
so update the tests accordingly.

The original code for reading from memory was included in 47ab5ad1457
("cmd_setexpr: allow memory addresses in expressions") but I am not adding
a Fixes: tag since that code was not written with 64-bit machines in mind.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index cab6fdf..e950c38 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -45,7 +45,7 @@
 	ut_assertok(run_command("setexpr.l fred 0", 0));
 	ut_asserteq_str("0", env_get("fred"));
 	ut_assertok(run_command("setexpr.l fred *0", 0));
-	ut_asserteq_str("ffffffff3456789a", env_get("fred"));
+	ut_asserteq_str("3456789a", env_get("fred"));
 
 	/* 64-bit */
 	*(u64 *)buf = 0x456789abcdef0123;
@@ -58,7 +58,7 @@
 	ut_assertok(run_command("setexpr fred 0", 0));
 	ut_asserteq_str("0", env_get("fred"));
 	ut_assertok(run_command("setexpr fred *0", 0));
-	ut_asserteq_str("456789abcdef0123", env_get("fred"));
+	ut_asserteq_str("cdef0123", env_get("fred"));
 
 	unmap_sysmem(buf);
 
@@ -90,7 +90,7 @@
 	*(u32 *)buf = 0x3456789a;
 	*(u32 *)(buf + 0x10) = 0xc3384235;
 	ut_assertok(run_command("setexpr.l fred *0 + *10", 0));
-	ut_asserteq_str("fffffffef78ebacf", env_get("fred"));
+	ut_asserteq_str("f78ebacf", env_get("fred"));
 
 	/* 64-bit */
 	*(u64 *)buf = 0x456789abcdef0123;
@@ -100,7 +100,7 @@
 
 	/* default */
 	ut_assertok(run_command("setexpr fred *0 + *10", 0));
-	ut_asserteq_str("8eeebc2f407393a6", env_get("fred"));
+	ut_asserteq_str("1407393a6", env_get("fred"));
 
 	unmap_sysmem(buf);
 
@@ -121,14 +121,14 @@
 
 	/* Quote | to avoid confusing hush */
 	ut_assertok(run_command("setexpr fred *0 \"|\" *10", 0));
-	ut_asserteq_str("ffffffff00561234", env_get("fred"));
+	ut_asserteq_str("561234", env_get("fred"));
 
 	*(u32 *)buf = 0x561200;
 	*(u32 *)(buf + 0x10) = 0x1234;
 
 	/* Quote & to avoid confusing hush */
 	ut_assertok(run_command("setexpr.l fred *0 \"&\" *10", 0));
-	ut_asserteq_str("ffffffff00001200", env_get("fred"));
+	ut_asserteq_str("1200", env_get("fred"));
 
 	ut_assertok(run_command("setexpr.l fred *0 ^ *10", 0));
 	ut_asserteq_str("560034", env_get("fred"));
@@ -137,13 +137,13 @@
 	ut_asserteq_str("55ffcc", env_get("fred"));
 
 	ut_assertok(run_command("setexpr.l fred *0 * *10", 0));
-	ut_asserteq_str("ffa9dbd21ebfa800", env_get("fred"));
+	ut_asserteq_str("61ebfa800", env_get("fred"));
 
 	ut_assertok(run_command("setexpr.l fred *0 / *10", 0));
-	ut_asserteq_str("1", env_get("fred"));
+	ut_asserteq_str("4ba", env_get("fred"));
 
 	ut_assertok(run_command("setexpr.l fred *0 % *10", 0));
-	ut_asserteq_str("55ffcc", env_get("fred"));
+	ut_asserteq_str("838", env_get("fred"));
 
 	unmap_sysmem(buf);