[U-Boot] [PATCH 1/2] lib: uuid: add function to generate UUID version 4

Stephen Warren swarren at wwwdotorg.org
Mon Mar 3 18:47:15 CET 2014


On 03/03/2014 06:44 AM, Przemyslaw Marczak wrote:
> Hello Stephen,
> Thank you for review.
> 
> On 02/28/2014 05:55 PM, Stephen Warren wrote:
>> On 02/28/2014 08:18 AM, Przemyslaw Marczak wrote:
>>> lib/uuid.c:
>>> Add get_uuid_str() - this function returns 36 character hexadecimal
>>> ASCII
>>> string representation of a 128-bit (16 octets) UUID (Universally Unique
>>> Identifier) version 4 based on RFC4122, which is randomly generated.
>>>
>>> Source: https://www.ietf.org/rfc/rfc4122.txt
>>
>>> diff --git a/disk/part_efi.c b/disk/part_efi.c
>>
>>> @@ -132,9 +113,11 @@ void print_part_efi(block_dev_desc_t * dev_desc)
>>>               le64_to_cpu(gpt_pte[i].ending_lba),
>>>               print_efiname(&gpt_pte[i]));
>>>           printf("\tattrs:\t0x%016llx\n", gpt_pte[i].attributes.raw);
>>> -        uuid_string(gpt_pte[i].partition_type_guid.b, uuid);
>>> +        uuid_bin = (unsigned char *)gpt_pte[i].partition_type_guid.b;
>>> +        uuid_bin_to_str(uuid_bin, uuid);
>>
>> I don't know why you need the uuid_bin temporary variable; you could
>> just as well do the cast as part of the function parameter. Not a big
>> deal though.
>
> Just because the line was too long.

You can wrap the parameter list.

>>> +char *get_uuid_str(void)
>>
>> This function name isn't particularly good; it gives no hint that it's
>> generating a random UUID. Perhaps generate_random_uuid_str() would be
>> better.
> 
> What about this?
> 
> /* To generate bin uuid */
> void gen_rand_uuid(unsigned char *uuid)

I don't think there's a need to shorten the words so much, but at least
that's accurate.


More information about the U-Boot mailing list