Skip to content

Conversation

@fangpeina
Copy link
Contributor

@fangpeina fangpeina commented Dec 17, 2025

Summary

A small improvements in the drivers/timers subsystem(including timer and watchdog drivers).
The changes focus on removing redundant or unreachable error-handling logic and improving
robustness checks using assertions, without altering the functional behavior of the drivers.

Impact

Users / Applications: No functional or behavioral changes.
Drivers: Affects drivers/timers/timer.c and drivers/timers/watchdog.c only.
Compatibility: No API or ABI changes.
Performance: No impact.
Security: No impact.

Testing

The changes were validated using existing driver test cases under testing/drivers, in QEMU、sim
and other physical device。apps/testing/drivers/drivertest/drivertest_timer.c
cmocka build case: drivertest_timer

@github-actions github-actions bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Dec 17, 2025
@fangpeina fangpeina closed this Dec 17, 2025
@fangpeina fangpeina changed the title drivers/timer drivers/timer: A small improvements in the drivers/timers subsystem Dec 17, 2025
@fangpeina fangpeina reopened this Dec 17, 2025
@acassis acassis requested a review from anchao December 17, 2025 11:43
jerpelea
jerpelea previously approved these changes Dec 18, 2025
@jerpelea jerpelea changed the title drivers/timer: A small improvements in the drivers/timers subsystem drivers/timers: A small improvements in the drivers/timers subsystem Dec 18, 2025
The reference count (upper->crefs) is incremented in timer_open()
only after ensuring it will not overflow, timer_close() is only
called after a successful open. Therefore, crefs should never be
zero when timer_close() is called. The check for crefs > 0 before
decrementing is unnecessary and has been removed to simplify the code.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
use DEBUGASSERT to check abnormal values in drivers/timers.c

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 5a22ad4 into apache:master Jan 8, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants