Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rimage: stop ignoring errors in parse_uuid() #8366

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Oct 20, 2023

3 commits.

Also fix compilation with clang 15

I checked that the MTL checksums are identical before/after these code changes.

assert() that sscanf returns the expected value.

Signed-off-by: Marc Herbert <[email protected]>
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]>
Add missing `const` and warn that the endianness can't be relied on.

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb
Copy link
Collaborator Author

marc-hb commented Oct 20, 2023

* Parse UUID hex string into a byte array. The endianness of the output
* is architecture-dependent: do not use in any portable code.
*/
void parse_uuid(const char *buf, uint8_t *uuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Rimage is part of sof repository can we add ifdef condition for Intel adsp?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to submit a follow-up PR after this one. This is one is just a minor clean-up.

@@ -294,8 +295,12 @@ void parse_uuid(char *buf, uint8_t *uuid)
struct uuid_t id;
uint32_t d[10];

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]);
Copy link
Collaborator

@lyakh lyakh Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to indent this, e.g. as

const int parsed_uuid_fields = sscanf(buf,
				      "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
				      ...

@kv2019i kv2019i merged commit 20705ad into thesofproject:main Oct 26, 2023
38 of 40 checks passed
@marc-hb marc-hb deleted the rimage-parse-uuid branch October 31, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants