[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/NEWLIB PATCH 6/6] syslog.c: Fix checkpatch warnings


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Wed, 14 Aug 2019 21:57:05 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, sharan.santhanam@xxxxxxxxx
  • Delivery-date: Wed, 14 Aug 2019 18:57:23 +0000
  • Ironport-phdr: 9a23:6nLpox9J/shApv9uRHKM819IXTAuvvDOBiVQ1KB21+wcTK2v8tzYMVDF4r011RmVBN+dsqgVwLSJ+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhWiDanfL9+MhG7oQrQu8QUnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahMxugqxGrhyvpBtxzIzaYIyOKPZyYrnQcc8ASGZdQspcUTFKDIOmb4sICuoMJfhVr47mp1sSrBu+AxSnCuXyyj9Qm3/9wKo33PgmEQHdwAwgHtQOvG7QrNXoLKcSTPu4w7XTzTnZd/NWxCzy5JLSchAmuPyBW697f8nJyUQ3Cg/IgUicpZbmMj6VzOgBrXaX4uh6We+hk2Irtg58riW1ysovioTFnJwZx17K+Clj3Yo4KsO0RUhmatC+CpRQrTuVN45uT8MnRGFnpTg1x6UduZ6+YCgK0JMnxwPDa/Cfc4iH/BbjVOGJLDdmgXJqYrO/hxKo/Ue80e3wTNG00EtRoSZfiNnMsWgB1x3V6seZVvtw5lqt1DmS2wzJ6exJIVo4mbTFJ5Mj2LI9mIIfsUHZES/3nEX2grWWdkIh+uWw9+vnZa7mpoOdN49ykA3+NrkumtSiAekjLgcORHKX+fyh1LL450H5WrJKguUskqbFqJDaOdgbpqmhDg9Q04Yj7Re/DzC90NgBgHYIMkxFdwyDj4XyP1HOIev4Deukg1i2nzZk2fbGMqfmApXXIXjJiK3hcqpl605A1AozyshS55xKBbEFIfLzQlH+uMbYDh8kMgy73+fnBc571owARW2PBrWWP7jIvVCW++IlO/OMa5MNuDbhN/gl4ObjjWQ5mVAHZ6mmx50XZGqjHvt8JUWZfXrsjc0HEWgQuwozV+rqh0OeXj5XfXm9RLgw6S8mCIi+F4fMWpitgKCd3Ce8BpBWfWFGClWLEXfubYmEWOoMZzyUIs5gjDMET6OsS4k/2h6ysA/10aFoIvDK9S0F5trf041w5uvSkgp3+TFqAsC112CWU3oyjm4OATgs0/NRu0t4n3yEyrR5hbR8CMROr6dCVRwmNJiay/FiFvj5QUTZY93PUlHwEYbuOi04Ut9km4xGWE16Adj31h0=
  • Ironport-sdr: vg8mQ8CoCqv/SV+ZtG3KxfUdSN2DOu1VRDcXWHF4iaDqJaH8FnD9FGlOiulsetnbrG19T9TP+V 4dGv6qImG84A==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.