casaroli commented on code in PR #21128:
URL: https://github.com/apache/nuttx/pull/21128#discussion_r4435273228
##########
libs/libc/syslog/lib_syslog.c:
##########
@@ -27,12 +27,77 @@
#include <nuttx/config.h>
#include <stdarg.h>
+#include <stdio.h>
#include <syslog.h>
+#include <unistd.h>
#include <nuttx/syslog/syslog.h>
+#include <nuttx/tls.h>
#include "syslog/syslog.h"
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if !defined(__KERNEL__) && defined(va_copy)
+/****************************************************************************
+ * Name: vsyslog_perror
+ *
+ * Description:
+ * With LOG_PERROR of openlog(), write the message to stderr too, with the
+ * ident and the process ID before it and a newline after it.
+ *
+ ****************************************************************************/
+
+static void vsyslog_perror(FAR const IPTR char *fmt, va_list ap)
+{
+ FAR struct task_info_s *info = task_get_info();
+ FAR const IPTR char *end;
+ va_list copy;
+ int option;
+
+ if (info == NULL
+#ifdef CONFIG_BUILD_FLAT
+ || up_interrupt_context()
+#endif
+ )
+ {
+ return;
+ }
+
+ option = info->ta_openlog.ol_option;
+ if ((option & LOG_PERROR) == 0)
+ {
+ return;
+ }
+
+ if ((option & LOG_PID) != 0)
+ {
+ dprintf(STDERR_FILENO, "%.*s[%d]: ", OPENLOG_IDENT_SIZE - 1,
+ info->ta_openlog.ol_ident, (int)getpid());
+ }
+ else if (info->ta_openlog.ol_ident[0] != '\0')
+ {
+ dprintf(STDERR_FILENO, "%.*s: ", OPENLOG_IDENT_SIZE - 1,
+ info->ta_openlog.ol_ident);
+ }
+
+ va_copy(copy, ap);
+ vdprintf(STDERR_FILENO, fmt, copy);
+ va_end(copy);
+
+ for (end = fmt; *end != '\0'; end++)
+ {
+ }
+
+ if (end == fmt || *(end - 1) != '\n')
Review Comment:
`fmt` is `FAR const IPTR char *`, and with `CONFIG_AVR_HAS_MEMX_PTR` `IPTR`
is `__memx`, but `strchr()` takes a generic pointer. `fputs()` walks its `IPTR`
string byte by byte for the same reason (libs/libc/stdio/lib_fputs.c).
--
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]