[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT/NEWLIB PATCH 6/6] syslog.c: Fix checkpatch warnings
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- musl-imported/src/syslog.c | 97 ++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/musl-imported/src/syslog.c b/musl-imported/src/syslog.c index 54a03e9..1792241 100644 --- a/musl-imported/src/syslog.c +++ b/musl-imported/src/syslog.c @@ -74,19 +74,21 @@ static int log_facility = LOG_USER; void openlog(const char *ident, int opt, int facility) { - LOCK(lock); - - if (ident) { - size_t n = strnlen(ident, sizeof log_ident - 1); - memcpy(log_ident, ident, n); - log_ident[n] = 0; - } else { - log_ident[0] = 0; - } - log_opt = opt; - log_facility = facility; - - UNLOCK(lock); + LOCK(lock); + + if (ident) { + size_t n; + + n = strnlen(ident, sizeof(log_ident) - 1); + memcpy(log_ident, ident, n); + log_ident[n] = 0; + } else { + log_ident[0] = 0; + } + log_opt = opt; + log_facility = facility; + + UNLOCK(lock); } void closelog(void) @@ -95,36 +97,41 @@ void closelog(void) void syslog(int priority, const char *message, ...) { - LOCK(lock); - - va_list ap; - va_start(ap, message); - - char timebuf[16]; - time_t now; - struct tm tm; - char buf[256]; - int pid; - int l, l2; - - if (!(priority & LOG_FACMASK)) priority |= log_facility; - - now = time(NULL); - gmtime_r(&now, &tm); - strftime(timebuf, sizeof timebuf, "%b %e %T", &tm); - - pid = (log_opt & LOG_PID) ? getpid() : 0; - l = snprintf(buf, sizeof buf, "<%d>%s %s%s%.0d%s: ", - priority, timebuf, log_ident, "["+!pid, pid, "]"+!pid); - l2 = vsnprintf(buf+l, sizeof buf - l, message, ap); - if (l2 >= 0) { - if (l2 >= sizeof buf - l) l = sizeof buf - 1; - else l += l2; - if (buf[l-1] != '\n') buf[l++] = '\n'; - fwrite(buf, 1, l, LOG_PRI(priority) >= LOG_ERR ? stderr : stdout); - } - - va_end(ap); - - UNLOCK(lock); + va_list ap; + char timebuf[16]; + time_t now; + struct tm tm; + char buf[256]; + int pid; + int l, l2; + + LOCK(lock); + + va_start(ap, message); + + if (!(priority & LOG_FACMASK)) + priority |= log_facility; + + now = time(NULL); + gmtime_r(&now, &tm); + strftime(timebuf, sizeof(timebuf), "%b %e %T", &tm); + + pid = (log_opt & LOG_PID) ? getpid() : 0; + l = snprintf(buf, sizeof(buf), "<%d>%s %s%s%.0d%s: ", priority, timebuf, + log_ident, "[" + !pid, pid, "]" + !pid); + l2 = vsnprintf(buf + l, sizeof(buf) - l, message, ap); + if (l2 >= 0) { + if (l2 >= (int) sizeof(buf) - l) + l = sizeof(buf) - 1; + else + l += l2; + if (buf[l - 1] != '\n') + buf[l++] = '\n'; + fwrite(buf, 1, l, + LOG_PRI(priority) >= LOG_ERR ? stderr : stdout); + } + + va_end(ap); + + UNLOCK(lock); } -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |