Skip to content

Commit

Permalink
rimage/toml_utils.c: remove uint32_t d0 shortcut in parse_uuid()
Browse files Browse the repository at this point in the history
Fixes compilation failure with clang 15:

rimage/src/toml_utils.c:297:67: error: taking address of packed member
  'd0' of class or structure 'uuid_t' may result in an unaligned pointer
  value [-Werror,-Waddress-of-packed-member]
  sscanf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &id.d0,
                                                                   ^~~~

This also aligns indexes.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and kv2019i committed Oct 26, 2023
1 parent a01fcc2 commit c180e8c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tools/rimage/src/toml_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,24 +293,25 @@ void parse_str_key(const toml_table_t *table, struct parse_ctx *ctx, const char
void parse_uuid(char *buf, uint8_t *uuid)
{
struct uuid_t id;
uint32_t d[10];
uint32_t d[11];

const int parsed_uuid_fields =
sscanf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &id.d0, &d[0],
&d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7], &d[8], &d[9]);
sscanf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &d[0],
&d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7], &d[8], &d[9], &d[10]);

assert(parsed_uuid_fields == 11);

id.d1 = (uint16_t)d[0];
id.d2 = (uint16_t)d[1];
id.d3 = (uint8_t)d[2];
id.d4 = (uint8_t)d[3];
id.d5 = (uint8_t)d[4];
id.d6 = (uint8_t)d[5];
id.d7 = (uint8_t)d[6];
id.d8 = (uint8_t)d[7];
id.d9 = (uint8_t)d[8];
id.d10 = (uint8_t)d[9];
id.d0 = d[0];
id.d1 = (uint16_t)d[1];
id.d2 = (uint16_t)d[2];
id.d3 = (uint8_t)d[3];
id.d4 = (uint8_t)d[4];
id.d5 = (uint8_t)d[5];
id.d6 = (uint8_t)d[6];
id.d7 = (uint8_t)d[7];
id.d8 = (uint8_t)d[8];
id.d9 = (uint8_t)d[9];
id.d10 = (uint8_t)d[10];

memcpy(uuid, &id, sizeof(id));
}
Expand Down

0 comments on commit c180e8c

Please sign in to comment.