diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-10-22 13:11:47 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-10-22 13:11:47 +0200 |
commit | 8a80f70a8afb2f6831b150a69cdf8f566deefe66 (patch) | |
tree | 4db787ad899ad3554b23eaebcaaf73a69dcfbc8e | |
parent | 21aa1add2bf2be4eb0d16a5efc897ccefa750ac6 (diff) | |
download | usbutils-8a80f70a8afb2f6831b150a69cdf8f566deefe66.tar.gz |
names.c: if a string can not be found in the usb.ids file, return [unknown]
For interfaces or other USB strings, if they are not in the current
hardware database, return "[unknown]" to give people a chance to
understand why their device isn't reporting anything for those fields.
This changes the output of a line that previous looked like:
|__ Port 004: Dev 006, If 0, Class=, Driver=, 12M
to be:
|__ Port 004: Dev 006, If 0, Class=[unknown], Driver=, 12M
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | names.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -192,7 +192,7 @@ int get_vendor_string(char *buf, size_t size, uint16_t vid) return 0; *buf = 0; if (!(cp = names_vendor(vid))) - return 0; + return snprintf(buf, size, "[unknown]"); return snprintf(buf, size, "%s", cp); } @@ -204,7 +204,7 @@ int get_product_string(char *buf, size_t size, uint16_t vid, uint16_t pid) return 0; *buf = 0; if (!(cp = names_product(vid, pid))) - return 0; + return snprintf(buf, size, "[unknown]"); return snprintf(buf, size, "%s", cp); } @@ -216,7 +216,7 @@ int get_class_string(char *buf, size_t size, uint8_t cls) return 0; *buf = 0; if (!(cp = names_class(cls))) - return 0; + return snprintf(buf, size, "[unknown]"); return snprintf(buf, size, "%s", cp); } @@ -228,7 +228,7 @@ int get_subclass_string(char *buf, size_t size, uint8_t cls, uint8_t subcls) return 0; *buf = 0; if (!(cp = names_subclass(cls, subcls))) - return 0; + return snprintf(buf, size, "[unknown]"); return snprintf(buf, size, "%s", cp); } |