[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v4] npiv: Auto-generate WWN if it's not specified



On 02/03/2012 11:05 AM, Eric Blake wrote:
>> +   if (virAsprintf(wwn, "%x%s%x%02x%02x%02x%02x", 0x5, QUMRANET_OUI,
> 
> Why not just:
> 
> if (virAsprintf(wwn, "5" QUMRANET_OUI "%010llx",
>                 (unsigned long long) virRandomBits(36)) < 0)

Correction - %09llx, for 36 bits of output from your random number.

I suppose you could also use

"5" QUMRANET_OUI "%09" PRIx64, virRandomBits(36)

to avoid the cast.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]