yamt commented on code in PR #15320:
URL: https://github.com/apache/nuttx/pull/15320#discussion_r1897007228


##########
libs/libc/stdio/lib_libvsprintf.c:
##########
@@ -911,6 +915,11 @@ static int vsprintf_internal(FAR struct lib_outstream_s 
*stream,
           size = 1;
           goto str_lpad;
 
+        case 'm': /* Print error message (%m) */
+          pnt = strerror(saved_errno);
+          size = strlen(pnt); /* Adjusting the size is not supported by %m */
+          goto str_lpad;
+

Review Comment:
   > > > > probably you can avoid errno access depending on the context.
   > > > > (using `up_interrupt_context` etc)
   > > > 
   > > > 
   > > > That won't tell you if you are running in a kernel thread or if you 
are in a system call.
   > > 
   > > 
   > > sure, besides that, i guess you should check OSINIT_xxx as well.
   > 
   > I think that we need a single new system call that answers the question: 
Is this called from the OS. That could be hard-coded in KERNEL mode but logic 
in other modes would have to test (1) if you are in an interrupt, (2) if you 
are sufficiently initialized, (3) if this is a kernel thread, and (4) if we are 
in a system call.
   > 
   > That, unfortunately, could be a pretty heavyweight solution.
   
   i think it's a good idea, given that we have similar checks here and there.
   
   i'm not sure how the system call check should be when system call is not 
enabled though.
   even in that case, we need some artificial user-kernel boundary if we want 
to implement a proper signal handling.
   



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to