I have been looking at the journalctl code and came across the following block of code.
It seems to be a shorthand way of exiting out of a series of condition tests if there is a non-zero result as the conditions are being tested. Pretty clever.
But I'm unsure about the purpose of the void
cast. Is it to suppress some compiler output? g++ does not care either way even with -Wall
and -pedantic -pedantic-errors
.
m1 = strjoina("_SYSTEMD_UNIT=", unit);
m2 = strjoina("COREDUMP_UNIT=", unit);
m3 = strjoina("UNIT=", unit);
m4 = strjoina("OBJECT_SYSTEMD_UNIT=", unit);
(void)(
/* Look for messages from the service itself */
(r = sd_journal_add_match(j, m1, 0)) ||
/* Look for coredumps of the service */
(r = sd_journal_add_disjunction(j)) ||
(r = sd_journal_add_match(j, "MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1", 0)) ||
(r = sd_journal_add_match(j, "_UID=0", 0)) ||
(r = sd_journal_add_match(j, m2, 0)) ||
/* Look for messages from PID 1 about this service */
(r = sd_journal_add_disjunction(j)) ||
(r = sd_journal_add_match(j, "_PID=1", 0)) ||
(r = sd_journal_add_match(j, m3, 0)) ||
/* Look for messages from authorized daemons about this service */
(r = sd_journal_add_disjunction(j)) ||
(r = sd_journal_add_match(j, "_UID=0", 0)) ||
(r = sd_journal_add_match(j, m4, 0))
);
f (r == 0 && endswith(unit, ".slice")) {
...