-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
vla: Use proper C99 flexible array #81895
base: main
Are you sure you want to change the base?
Conversation
0 length array is a GNU extension. Use proper flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
9179363
to
2a2a658
Compare
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
0 length array is a GNU extension. Use proper C99 flexible array. Signed-off-by: Flavio Ceolin <[email protected]>
Do I understand correctly that Since using the macro doesn't really improve readability (quite the opposite), I'm wondering, why don't we limit the macro usage only to the situations where the standard way can't directly be used, and use just |
@@ -755,7 +755,7 @@ struct bt_hci_handle_count { | |||
#define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035) /* 0x0c35 */ | |||
struct bt_hci_cp_host_num_completed_packets { | |||
uint8_t num_handles; | |||
struct bt_hci_handle_count h[0]; | |||
FLEXIBLE_ARRAY_DECLARE(struct bt_hci_handle_count, h); |
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.
Hi,
why not simply use foo[] instead of macro which adds some extra __unused_foo members under the hood?
also, this declares unpacked structures inside packed structure, are those guaranteed to not affect packed struct alignment or no padding requirements?
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.
@sjanc this was also my worry (see my earlier comment). I'd prefer if the macro was only used in the corner cases where you can't directly use []
.
As part of upcoming hardening buffer checks on Zephyr we need to sanitize the usage of flexible array. This pr properly declare flexible arrays according to C99 standard, not relying on non-portable GNU extension.