Currently the code interprets some properties as an array of strings
instead of hex constants. This tweaks the heuristics to make sure
/memory properties are more likely to be printed as hex.
ok?
Index: usr.sbin/eeprom/optree.c
===================================================================
RCS file: /cvs/src/usr.sbin/eeprom/optree.c,v
retrieving revision 1.8
diff -u -p -r1.8 optree.c
--- usr.sbin/eeprom/optree.c 21 May 2016 19:08:29 -0000 1.8
+++ usr.sbin/eeprom/optree.c 15 Oct 2017 22:18:46 -0000
@@ -36,22 +36,19 @@ static void
op_print(struct opiocdesc *opio, int depth)
{
char *p;
- int i, special;
+ int i, multi, special;
uint32_t cell;
opio->op_name[opio->op_namelen] = '\0';
printf("%*s%s: ", depth * 4, " ", opio->op_name);
if (opio->op_buflen > 0) {
opio->op_buf[opio->op_buflen] = '\0';
- special = 0;
+ multi = special = 0;
/*
- * XXX This allows multiple NUL characters within
- * string-valued properties, which may not be what we
- * want. But on macppc we have string-values
- * properties that end with multiple NUL characters,
- * and the serial number has them embedded within the
- * string.
+ * On macppc we have string-values properties that end
+ * with multiple NUL characters, and the serial number
+ * has them embedded within the string.
*/
if (opio->op_buf[0] != '\0') {
for (i = 0; i < opio->op_buflen; i++) {
@@ -61,10 +58,14 @@ op_print(struct opiocdesc *opio, int dep
if (*p == '\0') {
if (i + 1 < opio->op_buflen)
p++;
- if (*p >= ' ' && *p <= '~')
+ if (*p >= ' ' && *p <= '~') {
+ special = multi;
continue;
- if (*p == '\0')
+ }
+ if (*p == '\0') {
+ multi = 1;
continue;
+ }
}
special = 1;
@@ -75,7 +76,7 @@ op_print(struct opiocdesc *opio, int dep
special = 1;
}
- if (special) {
+ if (special && strcmp(opio->op_name, "serial-number") != 0) {
for (i = 0; opio->op_buflen - i >= sizeof(int);
i += sizeof(int)) {
if (i)