[U-Boot] [PATCH v4 5/6] cmd:gpt: randomly generate each partition uuid if undefined

Przemyslaw Marczak p.marczak at samsung.com
Thu Mar 27 10:17:41 CET 2014


On 03/26/2014 07:36 PM, Stephen Warren wrote:
> On 03/26/2014 06:01 AM, Przemyslaw Marczak wrote:
>> On 03/25/2014 08:51 PM, Stephen Warren wrote:
>>> On 03/19/2014 11:58 AM, Przemyslaw Marczak wrote:
>>>> Changes:
>>>> - randomly generate partition uuid if any is undefined and
>>>> CONFIG_RAND_UUID
>>>>     is defined
>>>> - print debug info about set/unset/generated uuid
>>>> - update doc/README.gpt
>>>>
>>>> Update existing code to the new library functions.
>
>>>> diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
>>>> -    if ((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}')) {
>>>> -        s = strdup(str);
>>>> -        if (s == NULL)
>>>> -            return -1;
>>>> -        memset(s + strlen(s) - 1, '\0', 1);
>>>> -        memmove(s, s + 2, strlen(s) - 1);
>>>> +    if (!((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}')))
>>>> +        return -1;
>>>
>>> Since you're inverting that test, you need to change && to || too.
>>>
>> No, because the invertion refers to the result of "if" - not one of
>> conditions.
>> !(cond1 && cond2) is the same as:
>> (!cond1 || !cond2)
>> so this change is ok.
>
> Ah yes, right.
>
>>>> diff --git a/doc/README.gpt b/doc/README.gpt
>>>> index 5c133f3..51515c8 100644
>>>> --- a/doc/README.gpt
>>>> +++ b/doc/README.gpt
>>>> @@ -101,7 +101,7 @@ Offset  Size    Description
>>>>    40      8 B     First usable LBA for partitions (primary partition
>>>> table last
>>>>            LBA + 1)
>>>>    48      8 B     Last usable LBA (secondary partition table first
>>>> LBA - 1)
>>>> -56      16 B    Disk GUID (also referred as UUID on UNIXes)
>>>> +56      16 B    Disk GUID (also referred as UUID on UNIXes) in big
>>>> endian
>>>
>>> According to your earlier comment, GUIDs have a mix of LE and BE fields,
>>> so I would simply drop this change and the similar change below. Let
>>> wikipedia or the comment you added near to top of lib/uuid.c specify the
>>> details.
>>>
>> Actually I think that this is an important info here. The information
>> about endianness is also placed in few places in lib/uuid.c
>
> Why isn't the endianness of all the fields in this structure defined in
> this comment then?
>
Right notice, I will add there more info.

Thanks
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com


More information about the U-Boot mailing list