[PATCH v5 02/11] lib: uuid: add UUID v5 support

Caleb Connolly caleb.connolly at linaro.org
Wed Jul 31 12:16:55 CEST 2024


>> +       /* Make little endian */
>> +       tmp32 = (uint32_t *)&guid->b[0];
>> +       *tmp32 = be32_to_cpu(*tmp32);
>> +       tmp16 = (uint16_t *)&guid->b[4];
>> +       *tmp16 = be16_to_cpu(*tmp16);
>> +       tmp16 = (uint16_t *)&guid->b[6];
>> +       *tmp16 = be16_to_cpu(*tmp16);
> 
> you need to explicitly convert those to LE, instead of relying to the
> native cpu endianess here

The EFI spec iirc is not explicit on the binary format for GUIDs on big 
endian systems (and currently doesn't support them at all??). Is LE 
always correct??
> 
> cheers
> /Ilias
>> +}
>> +
>>   #if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID)
>>   void gen_rand_uuid(unsigned char *uuid_bin)
>>   {
>>          u32 ptr[4];
>> @@ -394,15 +444,9 @@ void gen_rand_uuid(unsigned char *uuid_bin)
>>          /* Set all fields randomly */
>>          for (i = 0; i < 4; i++)
>>                  ptr[i] = rand();
>>
>> -       clrsetbits_be16(&uuid->time_hi_and_version,
>> -                       UUID_VERSION_MASK,
>> -                       UUID_VERSION << UUID_VERSION_SHIFT);
>> -
>> -       clrsetbits_8(&uuid->clock_seq_hi_and_reserved,
>> -                    UUID_VARIANT_MASK,
>> -                    UUID_VARIANT << UUID_VARIANT_SHIFT);
>> +       configure_uuid(uuid, UUID_VERSION);
>>
>>          memcpy(uuid_bin, uuid, 16);
>>   }
>>
>>
>> --
>> 2.45.2
>>

-- 
// Caleb (they/them)


More information about the U-Boot mailing list