diff options
author | Lennart Poettering <lennart@poettering.net> | 2025-01-16 13:46:18 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2025-01-16 20:09:12 +0100 |
commit | 83a3018e20d7e637e662fb98e05b41162aef54ac (patch) | |
tree | 625096eedf60c9ff50049dc12b12acdede40813d | |
parent | fundamental: unify gcc warning pragmas at one place (diff) | |
download | systemd-83a3018e20d7e637e662fb98e05b41162aef54ac.tar.xz systemd-83a3018e20d7e637e662fb98e05b41162aef54ac.zip |
nss-systemd: work around -Werror=zero-as-null-pointer-constant issue with PTHREAD_MUTEX_INITIALIZER
This fixes builds on Fedora:
../src/nss-systemd/nss-systemd.c:105:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
105 | .mutex = PTHREAD_MUTEX_INITIALIZER,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../src/nss-systemd/nss-systemd.c:105:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
../src/nss-systemd/nss-systemd.c:109:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
109 | .mutex = PTHREAD_MUTEX_INITIALIZER,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../src/nss-systemd/nss-systemd.c:109:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
../src/nss-systemd/nss-systemd.c:113:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
113 | .mutex = PTHREAD_MUTEX_INITIALIZER,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../src/nss-systemd/nss-systemd.c:113:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
../src/nss-systemd/nss-systemd.c:117:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
117 | .mutex = PTHREAD_MUTEX_INITIALIZER,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../src/nss-systemd/nss-systemd.c:117:18: error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]
cc1: all warnings being treated as errors
-rw-r--r-- | src/fundamental/macro-fundamental.h | 4 | ||||
-rw-r--r-- | src/nss-systemd/nss-systemd.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index 6122a0a92b..7bee2915e1 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -56,6 +56,10 @@ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wzero-length-bounds\"") +#define DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"") + #define REENABLE_WARNING \ _Pragma("GCC diagnostic pop") diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c index d686d920fc..683352fab9 100644 --- a/src/nss-systemd/nss-systemd.c +++ b/src/nss-systemd/nss-systemd.c @@ -101,6 +101,9 @@ typedef struct GetentData { bool by_membership; } GetentData; +/* On current glibc PTHREAD_MUTEX_INITIALIZER is defined in a way incompatible with + * -Wzero-as-null-pointer-constant, work around this for now. */ +DISABLE_WARNING_ZERO_AS_NULL_POINTER_CONSTANT; static GetentData getpwent_data = { .mutex = PTHREAD_MUTEX_INITIALIZER, }; @@ -116,6 +119,7 @@ static GetentData getspent_data = { static GetentData getsgent_data = { .mutex = PTHREAD_MUTEX_INITIALIZER, }; +REENABLE_WARNING; static void setup_logging_once(void) { static pthread_once_t once = PTHREAD_ONCE_INIT; |