diff --git a/include/syslog.h b/include/syslog.h index 66936e034d7..14c527cbce5 100644 --- a/include/syslog.h +++ b/include/syslog.h @@ -232,10 +232,6 @@ void vsyslog(int priority, FAR const IPTR char *fmt, va_list ap) * to a priority p is LOG_MASK(p); LOG_UPTO(p) provides the mask of all * priorities in the above list up to and including p. * - * Per OpenGroup.org "If the maskpri argument is 0, the current log mask - * is not modified." In this implementation, the value zero is permitted - * in order to disable all syslog levels. - * * NOTE: setlogmask is not a thread-safe, re-entrant function. Concurrent * use of setlogmask() will have undefined behavior. * diff --git a/libs/libc/syslog/lib_setlogmask.c b/libs/libc/syslog/lib_setlogmask.c index 8b60a604b6c..1ce329ef48b 100644 --- a/libs/libc/syslog/lib_setlogmask.c +++ b/libs/libc/syslog/lib_setlogmask.c @@ -55,10 +55,6 @@ uint8_t g_syslog_mask = CONFIG_SYSLOG_DEFAULT_MASK; * to a priority p is LOG_MASK(p); LOG_UPTO(p) provides the mask of all * priorities in the above list up to and including p. * - * Per OpenGroup.org "If the maskpri argument is 0, the current log mask - * is not modified." In this implementation, the value zero is permitted - * in order to disable all syslog levels. - * * NOTE: setlogmask is not a thread-safe, re-entrant function. Concurrent * use of setlogmask() will have undefined behavior. * @@ -80,8 +76,13 @@ int setlogmask(int mask) { uint8_t oldmask; - oldmask = g_syslog_mask; - g_syslog_mask = (uint8_t)mask; + oldmask = g_syslog_mask; + if (mask != 0) + { + /* If the mask argument is 0, the current logmask is not modified. */ + + g_syslog_mask = (uint8_t)mask; + } return oldmask; }