Skip to content

Conversation

heinwessels
Copy link
Contributor

@heinwessels heinwessels commented Oct 16, 2025

In 7d56d6a this conditional initializer was added with different requirements as what is used for the definition of xtensa_padding in struct cbprintf_package_desc. There was edge cases where the initializer was added when the field does not exist which was caught by clang-tidy. This commit ensures it uses the same conditions to add the padding initializer.


I could verify this by changing the struct cbprintf_package_desc which would cause a build error. Proving that the previous change would add the initialzier when the field didn't exist due to mismatching #if

// include/zephyr/sys/cbprintf.h

#ifdef __xtensa__

#if !defined(__cplusplus)
// This causes a build failure
#error "__xtensa__ is defined but __cplusplus is not set"
#endif


	/*
	 * On Xtensa, the first argument needs to be aligned to 8-byte.
	 * With 32-bit pointers, we need another 4 bytes padding so
	 * that whole struct cbprintf_package_hdr_ext is of multiple of
	 * 8 bytes.
	 */
	uint32_t xtensa_padding[Z_PKG_DESC_XTENSA_PADDING];
#endif

@zephyrbot zephyrbot added size: XS A PR changing only a single line of code area: Formatting Output labels Oct 16, 2025
In 7d56d6a this conditional initializer was added with different
requirements as what is used for the definition of cbprintf_package_desc.
There was edge cases where the initializer was added when the field does
not exist which was caught by clang-tidy. This commit ensures it uses
the same conditions to add the padding initializer.

Signed-off-by: Hein Wessels <[email protected]>
@heinwessels heinwessels force-pushed the invalid-field-designator branch from eccd62f to b71ca75 Compare October 16, 2025 11:00
Copy link

@dcpleung
Copy link
Member

I think we should use Zephyr Kconfig instead of some undocumented #define.

@heinwessels
Copy link
Contributor Author

I think we should use Zephyr Kconfig instead of some undocumented #define.

I do think that's important, but I do think it's more important that the two #ifs that dictate this behaviour should have the exact same conditions. So maybe either:

  • Leave this PR as is (both using __xtensa__)
  • Or change both instances to use CONFIG_XTENSA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Formatting Output size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants