[systemd-commits] 6 commits - .gitignore Makefile.am README src/core src/journal src/login src/sleep src/systemd src/timedate
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sat Oct 13 09:20:58 PDT 2012
.gitignore | 1
Makefile.am | 18 +++++-
README | 5 +
src/core/job.c | 6 +-
src/core/manager.c | 6 +-
src/core/unit.c | 2
src/journal/journal-gatewayd.c | 24 ++++-----
src/journal/journald-kmsg.c | 2
src/journal/journald-syslog.c | 7 +-
src/journal/journald-syslog.h | 2
src/journal/journald.c | 2
src/journal/journald.h | 3 -
src/journal/lookup3.c | 98 ++++++++++++++++++++------------------
src/journal/test-journal-syslog.c | 44 +++++++++++++++++
src/login/logind-dbus.c | 3 -
src/login/logind-seat.c | 4 -
src/login/logind-session.c | 4 -
src/sleep/sleep.c | 8 +--
src/systemd/sd-id128.h | 1
src/timedate/timedated.c | 4 -
20 files changed, 157 insertions(+), 87 deletions(-)
New commits:
commit b1bafc00d5137a27bb031e7104d9a8ca37362cca
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Oct 13 16:09:09 2012 +0000
journald: add missing include
./src/journal/journald.h:123:114: warning: âstruct ucredâ declared inside parameter list [enabled by default]
diff --git a/src/journal/journald.h b/src/journal/journald.h
index cd06b40..25e7ec3 100644
--- a/src/journal/journald.h
+++ b/src/journal/journald.h
@@ -22,8 +22,9 @@
***/
#include <inttypes.h>
-#include <sys/types.h>
#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/socket.h>
#include "journal-file.h"
#include "hashmap.h"
commit e4d1062c052337552f653b786a40377a5832d245
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Oct 13 13:13:50 2012 +0200
build-sys: always distribute file
diff --git a/Makefile.am b/Makefile.am
index ebefac3..e714b6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2699,9 +2699,6 @@ systemd_journal_gatewayd_CFLAGS = \
$(AM_CFLAGS) \
$(MICROHTTPD_CFLAGS)
-EXTRA_DIST += \
- units/systemd-journal-gatewayd.service.in
-
dist_systemunit_DATA += \
units/systemd-journal-gatewayd.socket
@@ -2713,6 +2710,9 @@ dist_gatewayddocumentroot_DATA = \
endif
+EXTRA_DIST += \
+ units/systemd-journal-gatewayd.service.in
+
# ------------------------------------------------------------------------------
if ENABLE_COREDUMP
systemd_coredump_SOURCES = \
commit 6374a73b007dfb03a738d6389ca34acd924f0379
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Oct 13 13:08:17 2012 +0200
journal-gatewayd: rename variables to avoid -Wshadow warning
diff --git a/src/journal/journal-gatewayd.c b/src/journal/journal-gatewayd.c
index b2d4abf..eea3530 100644
--- a/src/journal/journal-gatewayd.c
+++ b/src/journal/journal-gatewayd.c
@@ -276,20 +276,20 @@ static int request_parse_accept(
RequestMeta *m,
struct MHD_Connection *connection) {
- const char *accept;
+ const char *header;
assert(m);
assert(connection);
- accept = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Accept");
- if (!accept)
+ header = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Accept");
+ if (!header)
return 0;
- if (streq(accept, mime_types[OUTPUT_JSON]))
+ if (streq(header, mime_types[OUTPUT_JSON]))
m->mode = OUTPUT_JSON;
- else if (streq(accept, mime_types[OUTPUT_JSON_SSE]))
+ else if (streq(header, mime_types[OUTPUT_JSON_SSE]))
m->mode = OUTPUT_JSON_SSE;
- else if (streq(accept, mime_types[OUTPUT_EXPORT]))
+ else if (streq(header, mime_types[OUTPUT_EXPORT]))
m->mode = OUTPUT_EXPORT;
else
m->mode = OUTPUT_SHORT;
@@ -676,7 +676,7 @@ static int request_handler(
}
int main(int argc, char *argv[]) {
- struct MHD_Daemon *daemon = NULL;
+ struct MHD_Daemon *d = NULL;
int r = EXIT_FAILURE, n;
if (argc > 1) {
@@ -696,7 +696,7 @@ int main(int argc, char *argv[]) {
log_error("Can't listen on more than one socket.");
goto finish;
} else if (n > 0) {
- daemon = MHD_start_daemon(
+ d = MHD_start_daemon(
MHD_USE_THREAD_PER_CONNECTION|MHD_USE_POLL|MHD_USE_DEBUG,
19531,
NULL, NULL,
@@ -705,7 +705,7 @@ int main(int argc, char *argv[]) {
MHD_OPTION_NOTIFY_COMPLETED, request_meta_free, NULL,
MHD_OPTION_END);
} else {
- daemon = MHD_start_daemon(
+ d = MHD_start_daemon(
MHD_USE_DEBUG|MHD_USE_THREAD_PER_CONNECTION|MHD_USE_POLL,
19531,
NULL, NULL,
@@ -714,7 +714,7 @@ int main(int argc, char *argv[]) {
MHD_OPTION_END);
}
- if (!daemon) {
+ if (!d) {
log_error("Failed to start daemon!");
goto finish;
}
@@ -724,8 +724,8 @@ int main(int argc, char *argv[]) {
r = EXIT_SUCCESS;
finish:
- if (daemon)
- MHD_stop_daemon(daemon);
+ if (d)
+ MHD_stop_daemon(d);
return r;
}
commit e88baee88fad8bc59d33b55a7a2d640ef9e16cd6
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Oct 13 11:31:54 2012 +0200
journald: properly update message size after stripping the identifier
Valgrind says:
==29176== Conditional jump or move depends on uninitialised value(s)
==29176== at 0x412A85: cunescape_length_with_prefix (util.c:1565)
==29176== by 0x40B351: dev_kmsg_record (journald-kmsg.c:301)
==29176== by 0x40B653: server_read_dev_kmsg (journald-kmsg.c:347)
==29176== by 0x40B701: server_flush_dev_kmsg (journald-kmsg.c:365)
==29176== by 0x409DE7: main (journald.c:1535)
diff --git a/.gitignore b/.gitignore
index 71359ce..b9b333d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@
/build-aux
/test-watchdog
/test-journal-send
+/test-journal-syslog
/systemd-multi-seat-x
/systemd-cgtop
/systemd-coredump
diff --git a/Makefile.am b/Makefile.am
index 1c2514d..ebefac3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2462,6 +2462,15 @@ test_journal_send_LDADD = \
libsystemd-journal-internal.la \
libsystemd-id128-internal.la
+test_journal_syslog_SOURCES = \
+ src/journal/test-journal-syslog.c \
+ src/journal/journald-syslog.c
+
+test_journal_syslog_LDADD = \
+ libsystemd-shared.la \
+ libsystemd-journal-internal.la \
+ libsystemd-id128-internal.la
+
test_journal_match_SOURCES = \
src/journal/test-journal-match.c
@@ -2595,6 +2604,7 @@ UNINSTALL_EXEC_HOOKS += \
noinst_PROGRAMS += \
test-journal \
test-journal-send \
+ test-journal-syslog \
test-journal-match \
test-journal-stream \
test-journal-verify \
@@ -2602,6 +2612,8 @@ noinst_PROGRAMS += \
TESTS += \
test-journal \
+ test-journal-send \
+ test-journal-syslog \
test-journal-match \
test-journal-stream \
test-journal-verify \
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 4f5e7a0..548f653 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -275,7 +275,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) {
if ((priority & LOG_FACMASK) == LOG_KERN)
IOVEC_SET_STRING(iovec[n++], "SYSLOG_IDENTIFIER=kernel");
else {
- syslog_parse_identifier((const char**) &p, &identifier, &pid);
+ pl -= syslog_parse_identifier((const char**) &p, &identifier, &pid);
/* Avoid any messages we generated ourselves via
* log_info() and friends. */
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index d3e0f6f..c4f81b6 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -185,7 +185,7 @@ int syslog_fixup_facility(int priority) {
return priority;
}
-void syslog_parse_identifier(const char **buf, char **identifier, char **pid) {
+size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid) {
const char *p;
char *t;
size_t l, e;
@@ -201,7 +201,7 @@ void syslog_parse_identifier(const char **buf, char **identifier, char **pid) {
if (l <= 0 ||
p[l-1] != ':')
- return;
+ return 0;
e = l;
l--;
@@ -231,8 +231,9 @@ void syslog_parse_identifier(const char **buf, char **identifier, char **pid) {
if (t)
*identifier = t;
+ e += strspn(p + e, WHITESPACE);
*buf = p + e;
- *buf += strspn(*buf, WHITESPACE);
+ return e;
}
void syslog_parse_priority(char **p, int *priority) {
diff --git a/src/journal/journald-syslog.h b/src/journal/journald-syslog.h
index e009ab7..fa9de1a 100644
--- a/src/journal/journald-syslog.h
+++ b/src/journal/journald-syslog.h
@@ -26,7 +26,7 @@
int syslog_fixup_facility(int priority);
void syslog_parse_priority(char **p, int *priority);
-void syslog_parse_identifier(const char **buf, char **identifier, char **pid);
+size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid);
void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred, struct timeval *tv);
diff --git a/src/journal/test-journal-syslog.c b/src/journal/test-journal-syslog.c
new file mode 100644
index 0000000..3ae8633
--- /dev/null
+++ b/src/journal/test-journal-syslog.c
@@ -0,0 +1,44 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2011 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "journald-syslog.h"
+#include "macro.h"
+
+static void test_syslog_parse_identifier(const char* str,
+ const char *ident, const char*pid, int ret) {
+ const char *buf = str;
+ char *ident2 = NULL, *pid2 = NULL;
+ int ret2;
+
+ ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
+
+ assert(ret == ret2);
+ assert(ident==ident2 || !strcmp(ident, ident2));
+ assert(pid==pid2 || !strcmp(pid, pid2));
+}
+
+int main(void) {
+ test_syslog_parse_identifier("pidu[111]: xxx", "pidu", "111", 11);
+ test_syslog_parse_identifier("pidu: xxx", "pidu", NULL, 6);
+ test_syslog_parse_identifier("pidu xxx", NULL, NULL, 0);
+
+ return 0;
+}
commit 1b4bb4fdac4dce4e658aa3743153d77c04d1a331
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Oct 12 12:56:19 2012 +0000
journal: fix build in VALGRIND compatibility mode
diff --git a/README b/README
index 7b72b2e..25dadde 100644
--- a/README
+++ b/README
@@ -105,6 +105,11 @@ WARNINGS:
For more information on this issue consult
http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
+ To run systemd under valgrind, compile with VALGRIND defined
+ (e.g. ./configure CPPFLAGS='... -DVALGRIND=1'). Otherwise,
+ false positives will be triggered by code which violates
+ some rules but is actually safe.
+
ENGINEERING AND CONSULTING SERVICES:
ProFUSION <http://profusion.mobi> offers professional
engineering and consulting services for systemd for embedded
diff --git a/src/journal/lookup3.c b/src/journal/lookup3.c
index ee9a183..52ffdf7 100644
--- a/src/journal/lookup3.c
+++ b/src/journal/lookup3.c
@@ -337,23 +337,25 @@ uint32_t jenkins_hashlittle( const void *key, size_t length, uint32_t initval)
}
#else /* make valgrind happy */
-
- k8 = (const uint8_t *)k;
- switch(length)
{
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
- case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
- case 9 : c+=k8[8]; /* fall through */
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
- case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
- case 5 : b+=k8[4]; /* fall through */
- case 4 : a+=k[0]; break;
- case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
- case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
- case 1 : a+=k8[0]; break;
- case 0 : return c;
+ const uint8_t *k8 = (const uint8_t *) k;
+
+ switch(length)
+ {
+ case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
+ case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
+ case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
+ case 9 : c+=k8[8]; /* fall through */
+ case 8 : b+=k[1]; a+=k[0]; break;
+ case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
+ case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
+ case 5 : b+=k8[4]; /* fall through */
+ case 4 : a+=k[0]; break;
+ case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
+ case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
+ case 1 : a+=k8[0]; break;
+ case 0 : return c;
+ }
}
#endif /* !valgrind */
@@ -522,22 +524,24 @@ void jenkins_hashlittle2(
#else /* make valgrind happy */
- k8 = (const uint8_t *)k;
- switch(length)
{
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
- case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
- case 9 : c+=k8[8]; /* fall through */
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
- case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
- case 5 : b+=k8[4]; /* fall through */
- case 4 : a+=k[0]; break;
- case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
- case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
- case 1 : a+=k8[0]; break;
- case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */
+ const uint8_t *k8 = (const uint8_t *)k;
+ switch(length)
+ {
+ case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
+ case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
+ case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
+ case 9 : c+=k8[8]; /* fall through */
+ case 8 : b+=k[1]; a+=k[0]; break;
+ case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
+ case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
+ case 5 : b+=k8[4]; /* fall through */
+ case 4 : a+=k[0]; break;
+ case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
+ case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
+ case 1 : a+=k8[0]; break;
+ case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */
+ }
}
#endif /* !valgrind */
@@ -698,22 +702,24 @@ uint32_t jenkins_hashbig( const void *key, size_t length, uint32_t initval)
#else /* make valgrind happy */
- k8 = (const uint8_t *)k;
- switch(length) /* all the case statements fall through */
{
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=((uint32_t)k8[10])<<8; /* fall through */
- case 10: c+=((uint32_t)k8[9])<<16; /* fall through */
- case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */
- case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */
- case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */
- case 4 : a+=k[0]; break;
- case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */
- case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */
- case 1 : a+=((uint32_t)k8[0])<<24; break;
- case 0 : return c;
+ const uint8_t *k8 = (const uint8_t *)k;
+ switch(length) /* all the case statements fall through */
+ {
+ case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
+ case 11: c+=((uint32_t)k8[10])<<8; /* fall through */
+ case 10: c+=((uint32_t)k8[9])<<16; /* fall through */
+ case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */
+ case 8 : b+=k[1]; a+=k[0]; break;
+ case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */
+ case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */
+ case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */
+ case 4 : a+=k[0]; break;
+ case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */
+ case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */
+ case 1 : a+=((uint32_t)k8[0])<<24; break;
+ case 0 : return c;
+ }
}
#endif /* !VALGRIND */
commit 1ca6783f5ea3755bd83e723f529c2eda512c7fed
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Oct 8 17:02:30 2012 +0000
log: introduce a macro to format message id
The MESSAGE_ID=... stanza will appear in countless number of places.
It is just too long to write it out in full each time.
Incidentally, this also fixes a typo of MESSSAGE is three places.
diff --git a/src/core/job.c b/src/core/job.c
index 706910b..cb5674b 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -705,7 +705,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED;
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- "MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(mid),
+ MESSAGE_ID(mid),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
@@ -713,7 +713,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
} else if (t == JOB_STOP)
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- "MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_UNIT_STOPPED),
+ MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
@@ -721,7 +721,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
else if (t == JOB_RELOAD)
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- "MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_UNIT_RELOADED),
+ MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
diff --git a/src/core/manager.c b/src/core/manager.c
index 6fecbc3..b19fc3d 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2039,7 +2039,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
+ MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
"INITRD_USEC=%llu", (unsigned long long) initrd_usec,
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
@@ -2055,7 +2055,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
+ MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
"MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
@@ -2070,7 +2070,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
+ MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
"MESSAGE=Startup finished in %s.",
format_timespan(sum, sizeof(sum), total_usec),
diff --git a/src/core/unit.c b/src/core/unit.c
index ae43545..6396bfc 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1023,7 +1023,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
SD_MESSAGE_UNIT_RELOADING;
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(mid),
+ MESSAGE_ID(mid),
"UNIT=%s", u->id,
"MESSAGE=%s", buf,
NULL);
diff --git a/src/journal/journald.c b/src/journal/journald.c
index 0910d7d..4dcf7d3 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -725,7 +725,7 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format,
IOVEC_SET_STRING(iovec[n++], buffer);
if (!sd_id128_equal(message_id, SD_ID128_NULL)) {
- snprintf(mid, sizeof(mid), "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(message_id));
+ snprintf(mid, sizeof(mid), MESSAGE_ID(message_id));
char_array_0(mid);
IOVEC_SET_STRING(iovec[n++], mid);
}
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index cbf43fe..b95cc9b 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1180,8 +1180,7 @@ static int bus_manager_log_shutdown(
q = NULL;
}
- return log_struct(LOG_NOTICE,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SHUTDOWN),
+ return log_struct(LOG_NOTICE, MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
p,
q, NULL);
}
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 0ae0c52..470d08b 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -341,7 +341,7 @@ int seat_start(Seat *s) {
return 0;
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SEAT_START),
+ MESSAGE_ID(SD_MESSAGE_SEAT_START),
"SEAT_ID=%s", s->id,
"MESSAGE=New seat %s.", s->id,
NULL);
@@ -369,7 +369,7 @@ int seat_stop(Seat *s) {
if (s->started)
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SEAT_STOP),
+ MESSAGE_ID(SD_MESSAGE_SEAT_STOP),
"SEAT_ID=%s", s->id,
"MESSAGE=Removed seat %s.", s->id,
NULL);
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 958b516..5d9401b 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -547,7 +547,7 @@ int session_start(Session *s) {
return r;
log_struct(s->type == SESSION_TTY || s->type == SESSION_X11 ? LOG_INFO : LOG_DEBUG,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SESSION_START),
+ MESSAGE_ID(SD_MESSAGE_SESSION_START),
"SESSION_ID=%s", s->id,
"USER_ID=%s", s->user->name,
"LEADER=%lu", (unsigned long) s->leader,
@@ -689,7 +689,7 @@ int session_stop(Session *s) {
if (s->started)
log_struct(s->type == SESSION_TTY || s->type == SESSION_X11 ? LOG_INFO : LOG_DEBUG,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SESSION_STOP),
+ MESSAGE_ID(SD_MESSAGE_SESSION_STOP),
"SESSION_ID=%s", s->id,
"USER_ID=%s", s->user->name,
"LEADER=%lu", (unsigned long) s->leader,
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 71c7518..2f31267 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -69,13 +69,13 @@ int main(int argc, char *argv[]) {
if (streq(argv[1], "suspend"))
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SLEEP_START),
+ MESSAGE_ID(SD_MESSAGE_SLEEP_START),
"MESSAGE=Suspending system...",
"SLEEP=suspend",
NULL);
else
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SLEEP_START),
+ MESSAGE_ID(SD_MESSAGE_SLEEP_START),
"MESSAGE=Hibernating system...",
"SLEEP=hibernate",
NULL);
@@ -88,13 +88,13 @@ int main(int argc, char *argv[]) {
if (streq(argv[1], "suspend"))
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SLEEP_STOP),
+ MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
"MESSAGE=System resumed.",
"SLEEP=suspend",
NULL);
else
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_SLEEP_STOP),
+ MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
"MESSAGE=System thawed.",
"SLEEP=hibernate",
NULL);
diff --git a/src/systemd/sd-id128.h b/src/systemd/sd-id128.h
index 05521ae..fa17be8 100644
--- a/src/systemd/sd-id128.h
+++ b/src/systemd/sd-id128.h
@@ -65,6 +65,7 @@ static inline int sd_id128_equal(sd_id128_t a, sd_id128_t b) {
}
#define SD_ID128_NULL ((sd_id128_t) { .qwords = { 0, 0 }})
+#define MESSAGE_ID(x) "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(x)
#ifdef __cplusplus
}
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 8c589ba..40ba255 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -701,7 +701,7 @@ static DBusHandlerResult timedate_message_handler(
}
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_TIMEZONE_CHANGE),
+ MESSAGE_ID(SD_MESSAGE_TIMEZONE_CHANGE),
"TIMEZONE=%s", tz.zone,
"MESSAGE=Changed timezone to '%s'.", tz.zone,
NULL);
@@ -843,7 +843,7 @@ static DBusHandlerResult timedate_message_handler(
hwclock_set_time(tm);
log_struct(LOG_INFO,
- "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_TIME_CHANGE),
+ MESSAGE_ID(SD_MESSAGE_TIME_CHANGE),
"REALTIME=%llu", (unsigned long long) timespec_load(&ts),
"MESSAGE=Changed local time to %s", ctime(&ts.tv_sec),
NULL);
More information about the systemd-commits
mailing list