summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-06 12:48:23 -0500
committerSven Eden <yamakuzure@gmx.net>2017-07-17 17:58:34 +0200
commitee3f331e539dc37e88e558583c8a9a7a2383f5e0 (patch)
tree70d48583fde7115949f46bf2f72032d3927e0f31 /src/login/logind-dbus.c
parent2a4a438b7c7306da5f698d2247e646263f3c45c0 (diff)
tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_ID
Embedding sd_id128_t's in constant strings was rather cumbersome. We had SD_ID128_CONST_STR which returned a const char[], but it had two problems: - it wasn't possible to statically concatanate this array with a normal string - gcc wasn't really able to optimize this, and generated code to perform the "conversion" at runtime. Because of this, even our own code in coredumpctl wasn't using SD_ID128_CONST_STR. Add a new macro to generate a constant string: SD_ID128_MAKE_STR. It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition of the numbers, but in practice it is more convenient to use, and allows gcc to generate smarter code: $ size .libs/elogind{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/elogind.old 1260268 149564 4808 1414640 1595f0 .libs/elogind 246805 13852 209 260866 3fb02 .libs/elogind-logind.old 240973 13852 209 255034 3e43a .libs/elogind-logind 146839 4984 34 151857 25131 .libs/elogind-journald.old 146391 4984 34 151409 24f71 .libs/elogind-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/elogind.old|grep MESSAGE_ID MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x $ strings .libs/elogind|grep MESSAGE_ID MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27 MESSAGE_ID=b07a249cd024414a82dd00cd181378ff MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7 MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f MESSAGE_ID=d34d037fff1847e6ae669a370e694725 MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5 MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7 MESSAGE_ID=39f53479d3a045ac8e11786248231fbf MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d MESSAGE_ID=7b05ebc668384222baa8881179cfda54 MESSAGE_ID=9d1aaa27d60140bd96365438aad20286
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 26b6c3a92..971b447a7 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -34,7 +34,7 @@
#include "escape.h"
#include "fd-util.h"
#include "fileio-label.h"
-#include "formats-util.h"
+#include "format-util.h"
#include "fs-util.h"
#include "logind.h"
#include "mkdir.h"
@@ -1301,8 +1301,7 @@ static int flush_devices(Manager *m) {
} else {
struct dirent *de;
- while ((de = readdir(d))) {
-
+ FOREACH_DIRENT_ALL(de, d, break) {
if (!dirent_is_file(de))
continue;
@@ -1447,7 +1446,7 @@ static int bus_manager_log_shutdown(
p = strjoina(p, " (", m->wall_message, ").");
return log_struct(LOG_NOTICE,
- LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN),
+ "MESSAGE_ID=" SD_MESSAGE_SHUTDOWN_STR,
p,
q,
NULL);
@@ -2465,13 +2464,9 @@ static int method_set_wall_message(
return 1; /* Will call us back */
#endif // 0
- if (isempty(wall_message))
- m->wall_message = mfree(m->wall_message);
- else {
- r = free_and_strdup(&m->wall_message, wall_message);
- if (r < 0)
- return log_oom();
- }
+ r = free_and_strdup(&m->wall_message, empty_to_null(wall_message));
+ if (r < 0)
+ return log_oom();
m->enable_wall_messages = enable_wall_messages;