xiaoxiang781216 commented on code in PR #8012: URL: https://github.com/apache/nuttx/pull/8012#discussion_r1059477224
########## drivers/syslog/vsyslog.c: ########## @@ -128,7 +130,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) #if defined(CONFIG_SYSLOG_COLOR_OUTPUT) /* Reset the terminal style. */ - ret = lib_sprintf(&stream.public, "\e[0m"); + offset += sprintf(offset, "\e[0m"); Review Comment: could you add the perf number before/after optimization in the commit message? Please exclude the time spend in serial output. ########## drivers/syslog/vsyslog.c: ########## @@ -166,66 +168,66 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) switch (priority) { case LOG_EMERG: /* Red, Bold, Blinking */ - ret += lib_sprintf(&stream.public, "\e[31;1;5m"); + offset += sprintf(offset, "\e[31;1;5m"); Review Comment: can we use array to map priority to the color string? ########## drivers/syslog/vsyslog.c: ########## @@ -166,66 +168,66 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) switch (priority) { case LOG_EMERG: /* Red, Bold, Blinking */ - ret += lib_sprintf(&stream.public, "\e[31;1;5m"); + offset += sprintf(offset, "\e[31;1;5m"); break; case LOG_ALERT: /* Red, Bold */ - ret += lib_sprintf(&stream.public, "\e[31;1m"); + offset += sprintf(offset, "\e[31;1m"); break; case LOG_CRIT: /* Red, Bold */ - ret += lib_sprintf(&stream.public, "\e[31;1m"); + offset += sprintf(offset, "\e[31;1m"); break; case LOG_ERR: /* Red */ - ret += lib_sprintf(&stream.public, "\e[31m"); + offset += sprintf(offset, "\e[31m"); break; case LOG_WARNING: /* Yellow */ - ret += lib_sprintf(&stream.public, "\e[33m"); + offset += sprintf(offset, "\e[33m"); break; case LOG_NOTICE: /* Bold */ - ret += lib_sprintf(&stream.public, "\e[1m"); + offset += sprintf(offset, "\e[1m"); break; case LOG_INFO: /* Normal */ break; case LOG_DEBUG: /* Dim */ - ret += lib_sprintf(&stream.public, "\e[2m"); + offset += sprintf(offset, "\e[2m"); break; } #endif #if defined(CONFIG_SYSLOG_PRIORITY) /* Prepend the message priority. */ - ret += lib_sprintf(&stream.public, "[%6s] ", g_priority_str[priority]); + offset += sprintf(offset, "[%6s] ", g_priority_str[priority]); #endif #if defined(CONFIG_SYSLOG_PREFIX) /* Prepend the prefix, if available */ - ret += lib_sprintf(&stream.public, "[%s] ", CONFIG_SYSLOG_PREFIX_STRING); + offset += sprintf(offset, "[%s] ", CONFIG_SYSLOG_PREFIX_STRING); #endif #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_SYSLOG_PROCESS_NAME) /* Prepend the thread name */ tcb = nxsched_get_tcb(gettid()); - ret += lib_sprintf(&stream.public, "%s: ", - (tcb != NULL) ? tcb->name : "(null)"); + offset += sprintf(offset, "%s: ", (tcb != NULL) ? tcb->name : "(null)"); Review Comment: can we use one sprintf call to finish all possible format combination? like this: https://github.com/apache/nuttx/blob/master/sched/misc/assert.c#L327-L358 -- 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