mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
meson: enable -Wzero-as-null-pointer-constant (#36028)
Support for C added in gcc 15:
236c0829ee
This commit is contained in:
commit
30adccf3d4
@ -412,6 +412,7 @@ possible_common_cc_flags = [
|
||||
'-Wunterminated-string-initialization',
|
||||
'-Wunused-function',
|
||||
'-Wwrite-strings',
|
||||
'-Wzero-as-null-pointer-constant',
|
||||
'-Wzero-length-bounds',
|
||||
|
||||
# negative arguments are correctly detected starting with meson 0.46.
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
#include "MurmurHash2.h"
|
||||
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform-specific functions and macros
|
||||
|
@ -1,5 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <linux/magic.h>
|
||||
|
||||
#include "filesystems.h"
|
||||
|
@ -276,8 +276,7 @@ int locale_is_installed(const char *name) {
|
||||
if (STR_IN_SET(name, "C", "POSIX")) /* These ones are always OK */
|
||||
return true;
|
||||
|
||||
_cleanup_(freelocalep) locale_t loc =
|
||||
newlocale(LC_ALL_MASK, name, 0);
|
||||
_cleanup_(freelocalep) locale_t loc = newlocale(LC_ALL_MASK, name, (locale_t) 0);
|
||||
if (loc == (locale_t) 0)
|
||||
return errno == ENOMEM ? -ENOMEM : false;
|
||||
|
||||
|
@ -231,7 +231,7 @@ int lock_generic_with_timeout(int fd, LockType type, int operation, usec_t timeo
|
||||
.sigev_notify = SIGEV_SIGNAL,
|
||||
.sigev_signo = SIGALRM,
|
||||
};
|
||||
timer_t id = 0;
|
||||
timer_t id;
|
||||
|
||||
if (timer_create(CLOCK_MONOTONIC, &sev, &id) < 0) {
|
||||
log_error_errno(errno, "Failed to allocate CLOCK_MONOTONIC timer: %m");
|
||||
|
@ -268,8 +268,9 @@
|
||||
{%- endmacro -%}
|
||||
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "all-units.h"
|
||||
|
@ -2002,7 +2002,7 @@ static void manager_preset_all(Manager *m) {
|
||||
UnitFilePresetMode mode =
|
||||
ENABLE_FIRST_BOOT_FULL_PRESET ? UNIT_FILE_PRESET_FULL : UNIT_FILE_PRESET_ENABLE_ONLY;
|
||||
|
||||
r = unit_file_preset_all(RUNTIME_SCOPE_SYSTEM, 0, NULL, mode, NULL, 0);
|
||||
r = unit_file_preset_all(RUNTIME_SCOPE_SYSTEM, 0, NULL, mode, NULL, NULL);
|
||||
if (r < 0)
|
||||
log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r,
|
||||
"Failed to populate /etc with preset unit settings, ignoring: %m");
|
||||
|
@ -84,10 +84,10 @@
|
||||
# define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 7 || (defined(__clang__) && __clang_major__ >= 10)
|
||||
# define _fallthrough_ __attribute__((__fallthrough__))
|
||||
#else
|
||||
#if defined(__clang__) && __clang_major__ < 10
|
||||
# define _fallthrough_
|
||||
#else
|
||||
# define _fallthrough_ __attribute__((__fallthrough__))
|
||||
#endif
|
||||
|
||||
#define XSTRINGIFY(x) #x
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -1455,7 +1455,7 @@ static int manager_generate_key_pair(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to open key file for writing: %m");
|
||||
|
||||
if (PEM_write_PrivateKey(fprivate, m->private_key, NULL, NULL, 0, NULL, 0) <= 0)
|
||||
if (PEM_write_PrivateKey(fprivate, m->private_key, NULL, NULL, 0, NULL, NULL) <= 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to write private key pair.");
|
||||
|
||||
r = fflush_sync_and_check(fprivate);
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -319,7 +319,7 @@ static int hwdb_new(const char *path, sd_hwdb **ret) {
|
||||
if (file_offset_beyond_memory_size(hwdb->st.st_size))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EFBIG), "File %s is too long.", path);
|
||||
|
||||
hwdb->map = mmap(0, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
|
||||
hwdb->map = mmap(NULL, hwdb->st.st_size, PROT_READ, MAP_SHARED, fileno(hwdb->f), 0);
|
||||
if (hwdb->map == MAP_FAILED)
|
||||
return log_debug_errno(errno, "Failed to map %s: %m", path);
|
||||
|
||||
|
@ -55,9 +55,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||
# include <endian.h> /* attempt to define endianness */
|
||||
#endif
|
||||
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* My best guess at if you are big-endian or little-endian. This may
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "bareudp.h"
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <netinet/icmp6.h>
|
||||
#include <stddef.h>
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -330,7 +330,7 @@ static void test_oomd_mem_and_swap_free_below(void) {
|
||||
|
||||
static void test_oomd_sort_cgroups(void) {
|
||||
_cleanup_hashmap_free_ Hashmap *h = NULL;
|
||||
_cleanup_free_ OomdCGroupContext **sorted_cgroups;
|
||||
_cleanup_free_ OomdCGroupContext **sorted_cgroups = NULL;
|
||||
char **paths = STRV_MAKE("/herp.slice",
|
||||
"/herp.slice/derp.scope",
|
||||
"/herp.slice/derp.scope/sheep.service",
|
||||
@ -408,12 +408,11 @@ static void test_oomd_sort_cgroups(void) {
|
||||
assert_se(oomd_sort_cgroup_contexts(h, compare_pgscan_rate_and_memory_usage, "/herp.slice/derp.scope", &sorted_cgroups) == 2);
|
||||
assert_se(sorted_cgroups[0] == &ctx[2]);
|
||||
assert_se(sorted_cgroups[1] == &ctx[1]);
|
||||
assert_se(sorted_cgroups[2] == 0);
|
||||
assert_se(sorted_cgroups[3] == 0);
|
||||
assert_se(sorted_cgroups[4] == 0);
|
||||
assert_se(sorted_cgroups[5] == 0);
|
||||
assert_se(sorted_cgroups[6] == 0);
|
||||
sorted_cgroups = mfree(sorted_cgroups);
|
||||
ASSERT_NULL(sorted_cgroups[2]);
|
||||
ASSERT_NULL(sorted_cgroups[3]);
|
||||
ASSERT_NULL(sorted_cgroups[4]);
|
||||
ASSERT_NULL(sorted_cgroups[5]);
|
||||
ASSERT_NULL(sorted_cgroups[6]);
|
||||
}
|
||||
|
||||
static void test_oomd_fetch_cgroup_oom_preference(void) {
|
||||
|
@ -10,8 +10,9 @@ name, prefix, input = sys.argv[1:]
|
||||
|
||||
print("""\
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \\"-Wzero-as-null-pointer-constant\\"")
|
||||
#endif
|
||||
%}""")
|
||||
print("""\
|
||||
|
@ -1,5 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
#include "resolved-dnssd.h"
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -542,7 +542,7 @@ int mount_switch_root_full(const char *path, unsigned long mount_propagation_fla
|
||||
if (mount_propagation_flag == 0)
|
||||
return 0;
|
||||
|
||||
if (mount(NULL, ".", NULL, mount_propagation_flag | MS_REC, 0) < 0)
|
||||
if (mount(NULL, ".", NULL, mount_propagation_flag | MS_REC, NULL) < 0)
|
||||
return log_debug_errno(errno, "Failed to turn new rootfs '%s' into %s mount: %m",
|
||||
mount_propagation_flag_to_string(mount_propagation_flag), path);
|
||||
|
||||
|
@ -72,7 +72,7 @@ int apply_numa_policy(const NUMAPolicy *policy) {
|
||||
|
||||
assert(policy);
|
||||
|
||||
if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
|
||||
if (get_mempolicy(NULL, NULL, 0, NULL, 0) < 0 && errno == ENOSYS)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!numa_policy_is_valid(policy))
|
||||
|
@ -5201,8 +5201,8 @@ static int tpm2_calculate_seal_ecc_seed(
|
||||
r = ecc_pkey_to_curve_x_y(
|
||||
parent_pkey,
|
||||
&curve_id,
|
||||
/* ret_x= */ NULL, /* ret_x_size= */ 0,
|
||||
/* ret_y= */ NULL, /* ret_y_size= */ 0);
|
||||
/* ret_x= */ NULL, /* ret_x_size= */ NULL,
|
||||
/* ret_y= */ NULL, /* ret_y_size= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -151,7 +151,7 @@ static int pin_choice(
|
||||
r = chaseat(toplevel_fd,
|
||||
inode_path,
|
||||
CHASE_AT_RESOLVE_IN_ROOT,
|
||||
FLAGS_SET(flags, PICK_RESOLVE) ? &resolved_path : 0,
|
||||
FLAGS_SET(flags, PICK_RESOLVE) ? &resolved_path : NULL,
|
||||
inode_fd < 0 ? &inode_fd : NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -284,7 +284,7 @@ static int install_chld_handler(void) {
|
||||
.sa_handler = sigchld_hdl,
|
||||
};
|
||||
|
||||
if (sigaction(SIGCHLD, &act, 0) < 0)
|
||||
if (sigaction(SIGCHLD, &act, NULL) < 0)
|
||||
return log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
|
||||
|
||||
return 0;
|
||||
|
@ -955,7 +955,7 @@ TEST(read_full_file_socket) {
|
||||
_cleanup_close_ int rfd = -EBADF;
|
||||
/* child */
|
||||
|
||||
rfd = accept4(listener, NULL, 0, SOCK_CLOEXEC);
|
||||
rfd = accept4(listener, NULL, NULL, SOCK_CLOEXEC);
|
||||
assert_se(rfd >= 0);
|
||||
|
||||
assert_se(getpeername(rfd, &peer.sa, &peerlen) >= 0);
|
||||
|
@ -43,7 +43,7 @@ static void *fake_pressure_thread(void *p) {
|
||||
ASSERT_STREQ(buf, "hello");
|
||||
assert_se(write(cfd, &(const char) { 'z' }, 1) == 1);
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int fake_pressure_callback(sd_event_source *s, void *userdata) {
|
||||
|
@ -82,7 +82,7 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
|
||||
assert_se(sd_netlink_message_close_container(m) >= 0);
|
||||
assert_se(sd_netlink_message_close_container(m) >= 0);
|
||||
|
||||
assert_se(sd_netlink_call(rtnl, m, -1, 0) == 1);
|
||||
ASSERT_OK_POSITIVE(sd_netlink_call(rtnl, m, -1, NULL));
|
||||
|
||||
ASSERT_NULL((m = sd_netlink_message_unref(m)));
|
||||
|
||||
@ -108,7 +108,7 @@ static int test_tunnel_configure(sd_netlink *rtnl) {
|
||||
assert_se(sd_netlink_message_close_container(n) >= 0);
|
||||
assert_se(sd_netlink_message_close_container(n) >= 0);
|
||||
|
||||
assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1);
|
||||
ASSERT_OK_POSITIVE(sd_netlink_call(rtnl, n, -1, NULL));
|
||||
|
||||
ASSERT_NULL((n = sd_netlink_message_unref(n)));
|
||||
|
||||
|
@ -487,7 +487,7 @@ TEST(restrict_address_families) {
|
||||
safe_close(fd);
|
||||
|
||||
assert_se(s = set_new(NULL));
|
||||
assert_se(set_put(s, INT_TO_PTR(AF_UNIX)) >= 0);
|
||||
ASSERT_OK(set_put(s, INT_TO_PTR(AF_UNIX)));
|
||||
|
||||
assert_se(seccomp_restrict_address_families(s, false) >= 0);
|
||||
|
||||
@ -510,7 +510,7 @@ TEST(restrict_address_families) {
|
||||
|
||||
set_clear(s);
|
||||
|
||||
assert_se(set_put(s, INT_TO_PTR(AF_INET)) >= 0);
|
||||
ASSERT_OK(set_put(s, INT_TO_PTR(AF_INET)));
|
||||
|
||||
assert_se(seccomp_restrict_address_families(s, true) >= 0);
|
||||
|
||||
@ -751,7 +751,7 @@ TEST(restrict_archs) {
|
||||
assert_se(s = set_new(NULL));
|
||||
|
||||
#ifdef __x86_64__
|
||||
assert_se(set_put(s, UINT32_TO_PTR(SCMP_ARCH_X86+1)) >= 0);
|
||||
ASSERT_OK(set_put(s, UINT32_TO_PTR(SCMP_ARCH_X86+1)));
|
||||
#endif
|
||||
assert_se(seccomp_restrict_archs(s) >= 0);
|
||||
|
||||
@ -901,7 +901,7 @@ TEST(native_syscalls_filtered) {
|
||||
/* Passing "native" or an empty set is equivalent, just do both here. */
|
||||
assert_se(arch_s = set_new(NULL));
|
||||
assert_se(seccomp_restrict_archs(arch_s) >= 0);
|
||||
assert_se(set_put(arch_s, SCMP_ARCH_NATIVE) >= 0);
|
||||
ASSERT_OK(set_put(arch_s, (void*) SCMP_ARCH_NATIVE));
|
||||
assert_se(seccomp_restrict_archs(arch_s) >= 0);
|
||||
|
||||
assert_se(access("/", F_OK) >= 0);
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -6,8 +6,9 @@ set -eu
|
||||
awk '
|
||||
BEGIN {
|
||||
print "%{\n\
|
||||
#if __GNUC__ >= 7\n\
|
||||
_Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\
|
||||
#if __GNUC__ >= 15\n\
|
||||
_Pragma(\"GCC diagnostic ignored \\\"-Wzero-as-null-pointer-constant\\\"\")\n\
|
||||
#endif\n\
|
||||
%}"
|
||||
print "struct key_name { const char* name; unsigned short id; };"
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include "conf-parser.h"
|
||||
|
@ -98,7 +98,7 @@ static int show_user(UserRecord *ur, Table *table) {
|
||||
break;
|
||||
|
||||
case OUTPUT_JSON:
|
||||
sd_json_variant_dump(ur->json, arg_json_format_flags, NULL, 0);
|
||||
sd_json_variant_dump(ur->json, arg_json_format_flags, NULL, NULL);
|
||||
break;
|
||||
|
||||
case OUTPUT_FRIENDLY:
|
||||
@ -540,7 +540,7 @@ static int show_group(GroupRecord *gr, Table *table) {
|
||||
}
|
||||
|
||||
case OUTPUT_JSON:
|
||||
sd_json_variant_dump(gr->json, arg_json_format_flags, NULL, 0);
|
||||
sd_json_variant_dump(gr->json, arg_json_format_flags, NULL, NULL);
|
||||
break;
|
||||
|
||||
case OUTPUT_FRIENDLY:
|
||||
|
@ -16,8 +16,9 @@ if __name__ == '__main__':
|
||||
|
||||
print("""\
|
||||
%{
|
||||
#if __GNUC__ >= 7
|
||||
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
|
||||
#if __GNUC__ >= 15
|
||||
_Pragma("GCC diagnostic ignored \\"-Wzero-as-null-pointer-constant\\"")
|
||||
#endif
|
||||
%}""")
|
||||
print(f"""\
|
||||
|
Loading…
x
Reference in New Issue
Block a user