From 81cd8a229df847735c85909931cb4c4c12a96bfd Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 25 Feb 2025 17:38:46 -0600 Subject: [PATCH] lspci: Support 3+ digit register offsets 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 3abbe47b..001acb1a 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.39.5