Skip to content

Conversation

@wouterh
Copy link
Contributor

@wouterh wouterh commented May 23, 2025

timings is an array of struct i2c_config_timing (3 x uint32_t). i2c_timings_##index is an array of uint32_t (hence the cast when it is assigned to timings). Therefore ARRAY_SIZE(i2c_timings_##index) is off by a factor 3 when used for n_timings.

Parentheses around the second sizeof are there to silence the gcc warning (-Wsizeof-array-div) that warns about not computing the size of i2c_timings_##index.

`timings` is an array of `struct i2c_config_timing` (3 x `uint32_t`).
`i2c_timings_##index` is an array of `uint32_t` (hence the cast when it
is assigned to `timings`). Therefore `ARRAY_SIZE(i2c_timings_##index)` is
off by a factor 3 when used for `n_timings`.

Parentheses around the second `sizeof` are there to silence the gcc warning
(-Wsizeof-array-div) that warns about not computing the size of
`i2c_timings_##index`.

Signed-off-by: Wouter Horré <wouter@versasense.com>
@JarmouniA JarmouniA added the bug The issue is a bug, or the PR is fixing a bug label May 23, 2025
@sonarqubecloud
Copy link

@kartben kartben merged commit 5052919 into zephyrproject-rtos:main May 27, 2025
30 checks passed
@JarmouniA JarmouniA linked an issue May 27, 2025 that may be closed by this pull request
@JarmouniA JarmouniA added backport v3.7-branch Request backport to the v3.7-branch backport v4.0-branch labels May 27, 2025
@JarmouniA JarmouniA added backport v3.7-branch Request backport to the v3.7-branch and removed backport v3.7-branch Request backport to the v3.7-branch backport v4.0-branch labels Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: I2C backport v3.7-branch Request backport to the v3.7-branch bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: stm32 i2c: incorrect size of timings array

6 participants