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


##########
libs/libc/stdio/lib_libvsprintf.c:
##########
@@ -163,6 +163,10 @@ static int vsprintf_internal(FAR struct lib_outstream_s 
*stream,
   uint16_t flags;
   int width;
   int prec;
+
+  /* For the %m format we may need the current `errno' value */
+
+  int saved_errno = errno;

Review Comment:
   To summarize and take note for the future (feel free to correct me if I'm 
wrong):
   
   * When building in `protected` and `kernel` modes, the `%m` modifier could 
be excluded from `libc` by introducing conditional compilation.
   * When in flat builds, the code is shared among the user and kernel space.
   
   The problem lies in the fact that the `vsprintf` functions would be using 
the `errno` variable which points to garbage when calling from the kernel, in 
any build. Additionally, the code is being shared between user and kernel 
spaces, making it impossible to differentiate whether the caller is the OS or 
not.
   
   Potential solutions may imply having kernel-only code for `vsprintf` and 
relatives, whereas the user space makes use of the POSIX standard functions - 
this is, the current code. Additionally, some work will be needed to either 
have a "kernel" `syslog` or to re-route functions that rely on 
`syslog/vsprintf/...` when in the kernel (ie.: assertion and core dump logic).



-- 
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