diff options
author | Tom Rini <trini@konsulko.com> | 2019-07-29 11:51:17 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-07-29 11:51:17 -0400 |
commit | 2d64a0f7e952f54375702fb2b854461e402ded9d (patch) | |
tree | 591a1592b29de743bb52895ebb098ebc8b00f57a /lib/uuid.c | |
parent | 92430b8fc8aac3b4ab92e9ca8a09d83c4788c609 (diff) | |
parent | f043dc28e3cce115089fb9ab86bc6f4bc4a8a882 (diff) |
Merge branch '2019-07-29-master-imports'
- Assorted bug fixes
Diffstat (limited to 'lib/uuid.c')
-rw-r--r-- | lib/uuid.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/uuid.c b/lib/uuid.c index 7d7a2749b64..ca8be2cdca4 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -240,25 +240,25 @@ void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format) #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); } /* |