yangsong8-a1 opened a new pull request, #21835:
URL: https://github.com/apache/nuttx/pull/21835
## Summary
The watchdog upper half treats start and stop as required methods. It
calls them through the ops table without a check (WDIOC_START and
WDIOC_STOP only DEBUGASSERT; wdog_write() with a 'V', the panic notifier,
the auto-monitor and watchdog_unregister() do not check at all). The
optional methods are checked one by one in every ioctl.
Add WD_START/WD_STOP/WD_KEEPALIVE/WD_GETSTATUS/WD_SETTIMEOUT/WD_CAPTURE/
WD_IOCTL helpers to watchdog.h. They return -ENOSYS (-ENOTTY for ioctl,
NULL for capture) when the lower half does not implement the method. The
upper half uses them everywhere it calls the lower half.
## Impact
A lower half without start/stop now returns -ENOSYS instead of jumping to
NULL. One small difference: WDIOC_GETSTATUS with a NULL argument returns
-EINVAL even when the lower half has no getstatus (it returned -ENOSYS).
Nothing else changes for lower halves that implement the methods.
## Testing
Ubuntu 22.04, gcc 13.1.
sim:nsh + CONFIG_WATCHDOG + CONFIG_DEBUG_ASSERTIONS, with a test program
that registers two fake lower halves: /dev/wdfull (all methods) and
/dev/wdmin (keepalive only).
| Call | apache/master | This PR |
|---|---|---|
| /dev/wdfull: GETSTATUS, SETTIMEOUT, KEEPALIVE, unknown ioctl, write("x"),
write("V"), STOP, START | each calls its method, ret 0 (ioctl 123) | same |
| /dev/wdmin: GETSTATUS / SETTIMEOUT / unknown ioctl | ENOSYS / ENOSYS /
ENOTTY | same |
| /dev/wdmin: GETSTATUS(NULL) | ENOSYS | EINVAL |
| /dev/wdmin: write("x") | keepalive | keepalive |
| /dev/wdmin: write("V") | segmentation fault | ENOSYS |
| /dev/wdmin: WDIOC_STOP, WDIOC_START | not reached | ENOSYS, ENOSYS |
sim:taskmonitor (auto-monitor through WD_SETTIMEOUT/WD_START): the
watchdog is fed for 8 s idle, as on apache/master.
Also built without new warnings: sim:watchdog, sim:watchdog-notifier,
sim:ostest, stm32f746-ws:nsh, sam4s-xplained-pro:nsh, olimexino-stm32:nsh.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]