[libvirt] [PATCH] hostdev: display leading zeros of USB vendor/product id's in error messages

Chen Hanxiao chen_han_xiao at 126.com
Tue Aug 8 02:16:11 UTC 2017


At 2017-08-03 08:40:48, "John Ferlan" <jferlan at redhat.com> wrote:
>
>
>On 07/28/2017 04:33 AM, Chen Hanxiao wrote:
>> From: Chen Hanxiao <chenhanxiao at gmail.com>
>> 
>>     Many vendor id's and product id's have leading zeros.
>>     Show them in error messages.
>> 
>> Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
>> ---
>>  src/util/virhostdev.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>> 
>
>Looking at some other examples...
>
>    if (usbsrc->vendor) {
>        virBufferAsprintf(buf, "<vendor id='0x%.4x'/>\n", usbsrc->vendor);
>        virBufferAsprintf(buf, "<product id='0x%.4x'/>\n", usbsrc->product);
>
>and
>
>    if (usbdev->vendor >= 0)
>        virBufferAsprintf(buf, " vendor='0x%04X'", usbdev->vendor);
>
>    if (usbdev->product >= 0)
>        virBufferAsprintf(buf, " product='0x%04X'", usbdev->product);
>
>Perhaps the best thing to do is be consistent with all of them...  Could
>take a bit of searching, but cscope's egrep is pretty good w/
>"vendor.*%.*x" (and X).
>
>There's also a usage in libxl_conf, where "%x:%x" is used. So it may be
>best to find all possible print's of vendor and make them all consistent.
>

The %x:%x should be fixed.

x or X just show a different style.
Others like .4x, 04x have the same effect.
Maybe we should leave them untouched.

Regards,
- Chen




More information about the libvir-list mailing list