Skip to content

Commit 68053e8

Browse files
committed
include/errno.h: skip set_errno in interrupt context
set_errno() should not modify the interrupted task's errno. Add a check using up_interrupt_context() and skip the assignment when called from an interrupt handler. Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
1 parent 2b8be4a commit 68053e8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

include/errno.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
****************************************************************************/
2929

3030
#include <nuttx/compiler.h>
31+
#include <nuttx/irq.h>
3132

3233
/****************************************************************************
3334
* Pre-processor Definitions
@@ -44,7 +45,10 @@
4445
#define set_errno(e) \
4546
do \
4647
{ \
47-
errno = (int)(e); \
48+
if (!up_interrupt_context()) \
49+
{ \
50+
errno = (int)(e); \
51+
} \
4852
} \
4953
while (0)
5054
#define get_errno() errno

0 commit comments

Comments
 (0)