mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-26 09:57:26 +03:00
tree-wide: whenever we include libgen.h, immediately undefine basename()
Also, document in adjacent comments and in CODING_STYLE why we do that.
This commit is contained in:
parent
e89fe484df
commit
eef46c372f
@ -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!
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user