summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-12-05 08:55:19 -0600
committerTom Rini <[email protected]>2025-12-05 08:55:19 -0600
commitb3835a812fd94501f3d1417f5b099c1c25b24d00 (patch)
treed64e15b8ca888e33b3a1071d3e3f29c19907cdf1 /cmd
parentff258d03b914357c76cfea401ae4e4af39af521f (diff)
parente3d4ab528693419f809a9dcbbb697a7cd3be7086 (diff)
Merge patch series "test: let UNIT_TEST imply CONSOLE_RECORD"
Heinrich Schuchardt <[email protected]> says: Many C unit tests are not executed if CONFIG_CONSOLE_RECORD is not set. Hence Tom suggested to let UNIT_TEST imply CONSOLE_RECORD. The first patch makes the skipped C unit tests visible. The rest of the series deals with hidden bugs in our tests. The 'fdt get value' command returned incorrect values on low-endian systems. So this needed fixing too. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'cmd')
-rw-r--r--cmd/fdt.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/cmd/fdt.c b/cmd/fdt.c
index a67c30b21d5..d6d5b9fdfd2 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -9,14 +9,15 @@
#include <command.h>
#include <env.h>
+#include <fdt_support.h>
#include <image.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
#include <linux/ctype.h>
#include <linux/types.h>
-#include <asm/global_data.h>
#include <linux/libfdt.h>
-#include <fdt_support.h>
-#include <mapmem.h>
-#include <asm/io.h>
#define MAX_LEVEL 32 /* how deeply nested we will go */
#define SCRATCHPAD 1024 /* bytes of scratchpad memory */
@@ -91,18 +92,21 @@ static int fdt_value_env_set(const void *nodep, int len,
sprintf(buf, "0x%08X", fdt32_to_cpu(*(nodec + index)));
env_set(var, buf);
- } else if (len % 4 == 0 && len <= 20) {
+ } else {
/* Needed to print things like sha1 hashes. */
- char buf[41];
+ char *buf;
+ const unsigned int *nodec = (const unsigned int *)nodep;
int i;
- for (i = 0; i < len; i += sizeof(unsigned int))
+ buf = malloc(2 * len + 7);
+ if (!buf)
+ return CMD_RET_FAILURE;
+ for (i = 0; i < len; i += 4)
sprintf(buf + (i * 2), "%08x",
- *(unsigned int *)(nodep + i));
+ fdt32_to_cpu(*nodec++));
+ buf[2 * len] = 0;
env_set(var, buf);
- } else {
- printf("error: unprintable value\n");
- return 1;
+ free(buf);
}
return 0;
}