[systemd-commits] 3 commits - CODING_STYLE src/core src/libsystemd src/machine src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Feb 11 09:51:55 PST 2015
CODING_STYLE | 6 ++++++
src/core/execute.c | 2 --
src/core/unit.c | 2 +-
src/libsystemd/sd-bus/bus-kernel.c | 7 ++++++-
src/machine/machinectl.c | 5 +++++
src/shared/util.c | 6 +++++-
6 files changed, 23 insertions(+), 5 deletions(-)
New commits:
commit 418761f5864fe1ae7e9bb884259cc9933ae8ad0c
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 11 18:51:35 2015 +0100
core: correct a log message
The log message talks specifically about services, though it actually
applies to any kind of unit.
diff --git a/src/core/unit.c b/src/core/unit.c
index 2f95737..67425ba 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1653,7 +1653,7 @@ static void unit_check_binds_to(Unit *u) {
if (!stop)
return;
- log_unit_info(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id);
+ log_unit_info(u->id, "Unit %s is bound to inactive unit. Stopping, too.", u->id);
/* A unit we need to run is gone. Sniff. Let's stop this. */
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
commit eef46c372f64f40dd75415b2c504c73138719c8d
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 11 18:50:38 2015 +0100
tree-wide: whenever we include libgen.h, immediately undefine basename()
Also, document in adjacent comments and in CODING_STYLE why we do that.
diff --git a/CODING_STYLE b/CODING_STYLE
index 1d1d970..5574013 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -202,3 +202,9 @@
b) socket() and socketpair() must get SOCK_CLOEXEC passed
c) recvmsg() must get MSG_CMSG_CLOEXEC set
d) F_DUPFD_CLOEXEC should be used instead of F_DUPFD, and so on
+
+- We never use the XDG version of basename(). glibc defines it in
+ libgen.h. The only reason to include that file is because dirname()
+ is needed. Everytime you need that please immediately undefine
+ basename(), and add a comment about it, so that no code ever ends up
+ using the XDG version!
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 1714188..b884074 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -25,10 +25,15 @@
#include <fcntl.h>
#include <malloc.h>
-#include <libgen.h>
#include <sys/mman.h>
#include <sys/prctl.h>
+/* When we include libgen.h because we need dirname() we immediately
+ * undefine basename() since libgen.h defines it as a macro to the XDG
+ * version which is really broken. */
+#include <libgen.h>
+#undef basename
+
#include "util.h"
#include "strv.h"
#include "memfd-util.h"
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 16ce2f4..9f8c68b 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -31,8 +31,13 @@
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/mount.h>
+
+/* When we include libgen.h because we need dirname() we immediately
+ * undefine basename() since libgen.h defines it as a macro to the XDG
+ * version which is really broken. */
#include <libgen.h>
#undef basename
+
#include "sd-bus.h"
#include "log.h"
#include "util.h"
diff --git a/src/shared/util.c b/src/shared/util.c
index c53f9cd..f5fcebe 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -60,10 +60,14 @@
#include <locale.h>
#include <sys/personality.h>
#include <sys/xattr.h>
-#include <libgen.h>
#include <sys/statvfs.h>
#include <sys/file.h>
#include <linux/fs.h>
+
+/* When we include libgen.h because we need dirname() we immediately
+ * undefine basename() since libgen.h defines it as a macro to the XDG
+ * version which is really broken. */
+#include <libgen.h>
#undef basename
#ifdef HAVE_SYS_AUXV_H
commit e89fe484df6b94fcd775b923327b54eaf0a116e2
Author: Cristian RodrÃguez <crrodriguez at opensuse.org>
Date: Mon Feb 9 21:41:09 2015 -0300
core: remove unneeded <libgen.h> include
execute.c only uses basename (the GNU version in <string.h>)
diff --git a/src/core/execute.c b/src/core/execute.c
index 874cdc7..7b071e8 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -40,8 +40,6 @@
#include <sys/poll.h>
#include <glob.h>
#include <sys/personality.h>
-#include <libgen.h>
-#undef basename
#ifdef HAVE_PAM
#include <security/pam_appl.h>
More information about the systemd-commits
mailing list