You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Gary-Hobson (via GitHub)" <gi...@apache.org> on 2023/07/11 09:55:33 UTC

[GitHub] [nuttx] Gary-Hobson opened a new pull request, #9780: Fix syslog stack usage is too large

Gary-Hobson opened a new pull request, #9780:
URL: https://github.com/apache/nuttx/pull/9780

   ## Summary
   Using %pV in syslog will lead to nested calls, which will increase the stack consumption
   
   If LIBC_NUMBERED_ARGS is enabled, calling lib_sprintf in syslog will use a few hundred bytes of local variables, but syslog doesn't need it
   
   ## Impact
   
   ## Testing
   
   


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [nuttx] pkarashchenko commented on pull request #9780: Fix syslog stack usage is too large

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #9780:
URL: https://github.com/apache/nuttx/pull/9780#issuecomment-1632132515

   Please fix
   ```
   Error: stdio/lib_libvsprintf.c:1153:33: error: implicit declaration of function 'sprintf_internal' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                   sprintf_internal(stream,
   ```


-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9780: Fix syslog stack usage is too large

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9780:
URL: https://github.com/apache/nuttx/pull/9780#discussion_r1260858800


##########
drivers/syslog/vsyslog.c:
##########
@@ -148,107 +145,115 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
 #  endif
 #endif
 
-  ret = lib_sprintf(&stream.public,
+#if defined(CONFIG_SYSLOG_COLOR_OUTPUT) || defined(CONFIG_SYSLOG_TIMESTAMP) || \
+    defined(CONFIG_SMP) || defined(CONFIG_SYSLOG_PROCESSID) || \
+    defined(CONFIG_SYSLOG_PRIORITY) || defined(CONFIG_SYSLOG_PREFIX) || \
+    defined(CONFIG_SYSLOG_PROCESS_NAME)
+
+  ret = lib_sprintf_internal(&stream.public,
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Reset the terminal style. */
 
-                    "\e[0m"
+                             "\e[0m"
 #endif
 
 #ifdef CONFIG_SYSLOG_TIMESTAMP
 #  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
 #    if defined(CONFIG_SYSLOG_TIMESTAMP_FORMAT_MICROSECOND)
-                    "[%s.%06ld] "
+                             "[%s.%06ld] "
 #    else
-                    "[%s] "
+                             "[%s] "
 #    endif
 #  else
-                    "[%5jd.%06ld] "
+                             "[%5jd.%06ld] "
 #  endif
 #endif
 
 #if defined(CONFIG_SMP)
-                    "[CPU%d] "
+                             "[CPU%d] "
 #endif
 
 #if defined(CONFIG_SYSLOG_PROCESSID)
   /* Prepend the Thread ID */
 
-                    "[%2d] "
+                             "[%2d] "
 #endif
 
 #if defined(CONFIG_SYSLOG_COLOR_OUTPUT)
   /* Set the terminal style according to message priority. */
 
-                    "%s"
+                             "%s"
 #endif
 
 #if defined(CONFIG_SYSLOG_PRIORITY)
   /* Prepend the message priority. */
 
-                    "[%6s] "
+                             "[%6s] "
 #endif
 
 #if defined(CONFIG_SYSLOG_PREFIX)
   /* Prepend the prefix, if available */
 
-                    "[%s] "
+                             "[%s] "
 #endif
 #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME)
   /* Prepend the thread name */
 
-                    "%s: "
+                             "%s: "
 #endif
-                    "%pV"
 #ifdef CONFIG_SYSLOG_TIMESTAMP
 #  if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATTED)
 #    if defined(CONFIG_SYSLOG_TIMESTAMP_FORMAT_MICROSECOND)
-                    , date_buf, ts.tv_nsec / NSEC_PER_USEC
+                             , date_buf, ts.tv_nsec / NSEC_PER_USEC
 #    else
-                    , date_buf
+                             , date_buf
 #    endif
 #  else
-                    , (uintmax_t)ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC
+                             , (uintmax_t)ts.tv_sec
+                             , ts.tv_nsec / NSEC_PER_USEC
 #  endif
 #endif
 
 #if defined(CONFIG_SMP)
-                    , up_cpu_index()
+                             , up_cpu_index()
 #endif
 
 #if defined(CONFIG_SYSLOG_PROCESSID)
   /* Prepend the Thread ID */
 
-                    , nxsched_gettid()
+                             , (int)nxsched_gettid()

Review Comment:
   ```suggestion
                                , nxsched_gettid()
   ```



-- 
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-unsubscribe@nuttx.apache.org

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


[GitHub] [nuttx] pkarashchenko merged pull request #9780: Fix syslog stack usage is too large

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko merged PR #9780:
URL: https://github.com/apache/nuttx/pull/9780


-- 
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-unsubscribe@nuttx.apache.org

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