patacongo commented on code in PR #15320: URL: https://github.com/apache/nuttx/pull/15320#discussion_r1896765019
########## 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: > The problem is `syslog` uses the internals of the `vnprintf` to do the processing to reduce code duplication. This is widely used across `libc` variants, I attached an example script in the description. The is not the root cause of the issue. The cause is in the simulated process model. In BSD and Linux, the errno is declared as a simple global variable one per process. In NuttX, most users use the FLAT model which does not use the MMU and cannot support a true process model. Instead, the errno is retain in the TLS of the main thread of the process. Child threads keep a reference in TLS to the main threads TLS. When you access the errno, you have to chain through the TLS reference to find the errno. Interrupt handlers and kernel threads, on the other hand do not have TLS and hence to not have an errno. Attempts to access the non-existent TLS will have unpredictable results. System calls can have other TLS issues but tl;dr -- 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