summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2016-05-21 19:08:29 +0000
committerkettenis <kettenis@openbsd.org>2016-05-21 19:08:29 +0000
commitaddda549c93556679d186a7fe2bea0b840ce99ad (patch)
treeebb86be4eb30282c57defcddbe8c08bb9a04dc4a
parentZero op_name when we start enumerating properties such that we don't risk (diff)
downloadwireguard-openbsd-addda549c93556679d186a7fe2bea0b840ce99ad.tar.xz
wireguard-openbsd-addda549c93556679d186a7fe2bea0b840ce99ad.zip
Byteswap 32-bit "cells" on little-endian platforms before printing them.
OpenFirware/FDT is defined to be big-endian. This makes eeprom -p print sensible numbers on little-endian platforms. ok deraadt@
-rw-r--r--usr.sbin/eeprom/optree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/eeprom/optree.c b/usr.sbin/eeprom/optree.c
index f6cff9a7d3e..a2eaa29a8b2 100644
--- a/usr.sbin/eeprom/optree.c
+++ b/usr.sbin/eeprom/optree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optree.c,v 1.7 2016/05/21 19:06:15 kettenis Exp $ */
+/* $OpenBSD: optree.c,v 1.8 2016/05/21 19:08:29 kettenis Exp $ */
/*
* Copyright (c) 2007 Federico G. Schwindt <fgsch@openbsd.org>
@@ -37,6 +37,7 @@ op_print(struct opiocdesc *opio, int depth)
{
char *p;
int i, special;
+ uint32_t cell;
opio->op_name[opio->op_namelen] = '\0';
printf("%*s%s: ", depth * 4, " ", opio->op_name);
@@ -79,7 +80,8 @@ op_print(struct opiocdesc *opio, int depth)
i += sizeof(int)) {
if (i)
printf(".");
- printf("%08x", *(int *)(long)&opio->op_buf[i]);
+ cell = *(uint32_t *)&opio->op_buf[i];
+ printf("%08x", betoh32(cell));
}
if (i < opio->op_buflen) {
if (i)