-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Labels
area: APIChanges to public APIsChanges to public APIsarea: I2CbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug
Milestone
Description
Reported by Piotr Mienkowski:
Zephyr's I2C API contains the following construct
union dev_config {
u32_t raw;
struct __bits {
u32_t use_10_bit_addr : 1;
u32_t speed : 3;
u32_t is_master_device : 1;
u32_t reserved : 26;
} bits;
};
This is incorrect. C99 §6.7.2.1, paragraph 10 says: "The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined.". I.e. - using union dev_config as an example - compiler is free to map use_10_bit_addr either to MSB or to LSB. The two methods of specifying bit fields are not equivalent and should not be mixed.
(Imported from Jira ZEP-2579)
Metadata
Metadata
Assignees
Labels
area: APIChanges to public APIsChanges to public APIsarea: I2CbugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bugLow impact/importance bug