masc2008 opened a new pull request, #18839: URL: https://github.com/apache/nuttx/pull/18839
## Summary * **Why:** `errno` is defined as a per-thread value. When `set_errno()` is called from an interrupt handler, it currently modifies the interrupted task's `errno`, which violates POSIX semantics because the interrupted task did not request the failing operation. * **What:** Add an `up_interrupt_context()` guard inside the `set_errno()` macro so that the assignment is skipped when running in an interrupt handler. * **How:** Include `<nuttx/irq.h>` and wrap the `errno = (int)(e)` assignment with `if (!up_interrupt_context())`. ## Impact * Is new feature added? Is existing feature changed? NO * Impact on user (will user need to adapt to change)? NO * Impact on build (will build process change)? NO * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO * Impact on documentation (is update required / provided)? NO * Impact on security (any sort of implications)? NO * Impact on compatibility (backward/forward/interoperability)? NO * Anything else to consider or add? This is a defensive fix that prevents silent corruption of a task's errno by ISR code. ## Testing I confirm that changes are verified on local setup and works as intended: * Build Host(s): Linux x86_64, GCC 13.4.0 (arm-none-eabi) * Target(s): arm/qemu-armv7a:full Testing logs after change: there is no log when do it, I tested this under qemu-armv7a and BES chip. -- 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]
