-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix format specifiers zassert strings #96906
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
Changes from all commits
8eb7121
6a4e22e
195c060
d569522
94d8acc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
#include <zephyr/sys/timeutil.h> | ||
|
||
/* arbitrary magic numbers used for testing */ | ||
#define BIOS_FOOD 0xb105f00d | ||
#define BIOS_FOOD 0xb105f00dUL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the best way to represent a |
||
#define FORTY_TWO 42 | ||
#define SEVENTY_THREE 73 | ||
#define DONT_CARE 0x370ca2e5 | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param
isuintptr_t
, which is not a type that printf knows about internally. Include<inttypes.h>
and use"%" PRIuPTR
for both, adding a cast to(uintptr_t)
forBIOS_FOOD
so they match.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use
PRIuPTR
or others frominttypes.h
, as they are not widely used in Zephyr. A quick search showed only three occurrences ofPRIuPTR
. As far as I know, in Zephyr's type system,PRIuPTR
is alwayslu
.#37718 (comment)
If there is consensus to start using defines from
inttypes.h
, I'm happy to use them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several people have commented that the inttypes.h stuff is not their favorite, to the point that Zephyr attempts to enforce some level of type uniformity. It usually overrides the toolchain types by pre-loading
zephyr_stdint.h
. you can use%lu
withuintptr_t
and%d
withint32_t
whenCONFIG_ENFORCE_ZEPHYR_STDINT
is set.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a safe option would be to cast both parameters to
(unsigned long)
and use "%ul" (this is a error print at the end)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, a reasonable plan (although, I think you meant
%lu
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, a cast + lu would work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I used now the cast +
lu
, see #97202