nuttx/arch
Aurora-QIU0 86159f3353 risc-v/espressif: Fix I2C polling wait timeout comparison.
clock_t is an unsigned type unless CONFIG_SYSTEM_TIME64 is selected, as
documented in sys/types.h.  The difference in

    while (current - timeout < 0 && priv->error == 0)

therefore underflows to a large positive value instead of being
negative, the comparison is always false, and the loop body never runs.
status keeps its initial value of zero and the function returns OK
without having waited for the transfer at all.

Because the polling path reports completion immediately, every transfer
looks successful: no timeout is ever raised and register reads return
whatever the RX FIFO happens to contain.  The function is compiled in
under CONFIG_I2C_POLLED, which boards use when the I2C interrupt is not
wired up.

Cast the difference to int32_t to get the intended signed comparison.
The result also stays correct across the counter wrap, as long as the
timeout is shorter than the counter range, which SEC2TICK(10) satisfies.

Since this file is modified by this commit, the pre-existing nxstyle
violations reported by the check job are fixed as well, as asked in
CONTRIBUTING.md section 2.1 (adapt all modified files even if you did
not introduce the problem yourself):

* esp_i2c.c:1267      - statement over-indented inside its enclosing
                        block (8 spaces where the block body is at 6)
* esp_i2c.c:1303      - missing blank line after declarations
* esp_i2c.c:1592      - missing blank line after declarations
* esp_i2c.c:1710-1725 - 'case'/'default' labels inside switch(port)
                        sat at the same indent as the brace opening
                        the switch body; they belong one level further
                        in, with the case logic one more level in from
                        the label

Assisted-by: WorkBuddy:DeepSeek-V4.1-Flash
Signed-off-by: Aurora-QIU0 <2170685247@qq.com>
2026-09-18 15:59:11 +08:00
..
arm arch/arm/stm32: fix compare-match race and zero-period hang in tickless 2026-09-18 09:30:22 +08:00
arm64 arch/arm/imx9, arch/arm64/imx9: Release eDMA lock before callbacks 2026-09-15 08:41:58 -03:00
avr arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
ceva arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
dummy
hc tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
mips arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
misoc arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
or1k arch, boards, cmake: Build C++ ELF modules without __cxa_atexit. 2026-09-04 15:44:24 -03:00
renesas nuttx/libc: refine the atomic related Kconfig 2026-08-24 13:20:45 +08:00
risc-v risc-v/espressif: Fix I2C polling wait timeout comparison. 2026-09-18 15:59:11 +08:00
sim arch/sim: Add runtime HCI socket target option 2026-09-13 18:31:59 -03:00
sparc arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
tricore arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
x86 arch/x86: Add -P to CPP to suppress linemarkers. 2026-09-17 16:21:59 +08:00
x86_64 arch/intel64: don't touch the outgoing stack after releasing the csection 2026-09-15 11:39:05 -03:00
xtensa xtensa/espressif: fix lock-order deadlock in esp_wifi_event_handler() 2026-09-18 15:57:44 +08:00
z16 tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00
z80 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
CMakeLists.txt cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) 2026-08-09 11:13:08 -03:00
Kconfig binfmt, arch/arm: Add the CONFIG_FDPIC option and the ABI header. 2026-09-08 16:31:16 -03:00