[Toybox] [PATCH] lspci: Support 3+ digit register offsets

Brian Norris briannorris at google.com
Tue Feb 25 14:09:48 PST 2025


When dumping registers with -xxxx, addresses will be larger than 2 hex
digits (256), which means we truncate the column/address. This can
confuse attempts at post-processing this output.
---
 toys/other/lsusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c
index 3abbe47b60de..001acb1aebd3 100644
--- a/toys/other/lsusb.c
+++ b/toys/other/lsusb.c
@@ -241,7 +241,7 @@ static int list_pci(struct dirtree *new)
     snprintf(toybuf, sizeof(toybuf), "/sys/bus/pci/devices/%s/config", new->name);
     fp = xfopen(toybuf, "r");
     while ((b = fgetc(fp)) != EOF) {
-      if ((col % 16) == 0) printf("%02x: ", col & 0xf0);
+      if ((col % 16) == 0) printf("%02x: ", col & ~0xf);
       printf("%02x ", (b & 0xff));
       if ((++col % 16) == 0) xputc('\n');
       if (col == max) break;
-- 
2.48.1.658.g4767266eb4-goog



More information about the Toybox mailing list