#if defined(CONFIG_RANDOM_UUID) || defined(CONFIG_CMD_UUID)
void gen_rand_uuid(unsigned char *uuid_bin)
{
- struct uuid uuid;
- unsigned int *ptr = (unsigned int *)&uuid;
+ u32 ptr[4];
+ struct uuid *uuid = (struct uuid *)ptr;
int i;
srand(get_ticks() + rand());
/* Set all fields randomly */
- for (i = 0; i < sizeof(struct uuid) / sizeof(*ptr); i++)
- *(ptr + i) = cpu_to_be32(rand());
+ for (i = 0; i < 4; i++)
+ ptr[i] = rand();
- clrsetbits_be16(&uuid.time_hi_and_version,
+ clrsetbits_be16(&uuid->time_hi_and_version,
UUID_VERSION_MASK,
UUID_VERSION << UUID_VERSION_SHIFT);
- clrsetbits_8(&uuid.clock_seq_hi_and_reserved,
+ clrsetbits_8(&uuid->clock_seq_hi_and_reserved,
UUID_VARIANT_MASK,
UUID_VARIANT << UUID_VARIANT_SHIFT);
- memcpy(uuid_bin, &uuid, sizeof(struct uuid));
+ memcpy(uuid_bin, uuid, 16);
}
/*