Skip to contentSkip to conversation

change auto filter output format of "info usbhost" (v1)

PATCH New Andreas Winkelbauer 1 participant 1 message Sep 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 change auto filter output format of "info usbhost" (v1)

This patch changes the output format of the monitor command "info usbhost" for usb auto filters in usb_host_info().

The VID and PID are now printed as 4 digit hexadecimal numbers with leading zeros (which is much more usual compared to the current output format which does not print leading zeros).

---

bye,
Andi

usb-linux.c +3 -3
diff -uNrp trunk.orig/usb-linux.c trunk/usb-linux.c
@@ -1462,7 +1462,7 @@ static void hex2str(int val, char *str)
     if (val == -1)
         strcpy(str, "*");
     else
-        sprintf(str, "%x", val);
+        sprintf(str, "%04x", val);
 }
 
 void usb_host_info(void)
@@ -1474,12 +1474,12 @@ void usb_host_info(void)
     if (usb_auto_filter)
         term_printf("  Auto filters:\n");
     for (f = usb_auto_filter; f; f = f->next) {
-        char bus[10], addr[10], vid[10], pid[10];
+        char bus[10], addr[10], vid[5], pid[5];
         dec2str(f->bus_num, bus);
         dec2str(f->addr, addr);
         hex2str(f->vendor_id, vid);
         hex2str(f->product_id, pid);
-    	term_printf("    Device %s.%s ID %s:%s\n", bus, addr, vid, pid);
+        term_printf("    Device %s.%s ID %s:%s\n", bus, addr, vid, pid);
     }
 }