blobmsg: add blobmsg_parse_array_attr
[project/libubox.git] / ulog.c
diff --git a/ulog.c b/ulog.c
index 776a0c4e869d47890036e0b7e7fa2b6c5aaf14e5..05946a0c352154c15e1fc4b28e3e8110e668c075 100644 (file)
--- a/ulog.c
+++ b/ulog.c
@@ -35,12 +35,13 @@ static const char *ulog_default_ident(void)
        FILE *self;
        static char line[64];
        char *p = NULL;
+       char *sbuf;
 
        if ((self = fopen("/proc/self/status", "r")) != NULL) {
                while (fgets(line, sizeof(line), self)) {
                        if (!strncmp(line, "Name:", 5)) {
-                               strtok(line, "\t\n");
-                               p = strtok(NULL, "\t\n");
+                               strtok_r(line, "\t\n", &sbuf);
+                               p = strtok_r(NULL, "\t\n", &sbuf);
                                break;
                        }
                }
@@ -86,11 +87,12 @@ static void ulog_defaults(void)
        _ulog_initialized = 1;
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_kmsg(int priority, const char *fmt, va_list ap)
 {
        FILE *kmsg;
 
-       if ((kmsg = fopen("/dev/kmsg", "w")) != NULL) {
+       if ((kmsg = fopen("/dev/kmsg", "r+")) != NULL) {
                fprintf(kmsg, "<%u>", priority);
 
                if (_ulog_ident)
@@ -101,19 +103,18 @@ static void ulog_kmsg(int priority, const char *fmt, va_list ap)
        }
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_stdio(int priority, const char *fmt, va_list ap)
 {
        FILE *out = stderr;
 
-       if (priority == LOG_INFO || priority == LOG_NOTICE)
-               out = stdout;
-
        if (_ulog_ident)
                fprintf(out, "%s: ", _ulog_ident);
 
        vfprintf(out, fmt, ap);
 }
 
+__attribute__((format(printf, 2, 0)))
 static void ulog_syslog(int priority, const char *fmt, va_list ap)
 {
        vsyslog(priority, fmt, ap);