From 7f4b3dc043cfb2954d0b492693f105fd55e3c874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 31 Jul 2023 14:04:55 +0200 Subject: [PATCH 1/2] gpt-auto-generator: fix warnings about unused func when !ENABLE_EFI --- src/gpt-auto-generator/gpt-auto-generator.c | 54 ++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 585aaae2ed..fed670e7f4 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -487,33 +487,6 @@ static int slash_boot_in_fstab(void) { return cache; } -static int slash_efi_in_fstab(void) { - static int cache = -1; - - if (cache >= 0) - return cache; - - cache = fstab_is_mount_point("/efi"); - if (cache < 0) - return log_error_errno(cache, "Failed to parse fstab: %m"); - return cache; -} - -static bool slash_boot_exists(void) { - static int cache = -1; - - if (cache >= 0) - return cache; - - if (access("/boot", F_OK) >= 0) - return (cache = true); - if (errno != ENOENT) - log_error_errno(errno, "Failed to determine whether /boot/ exists, assuming no: %m"); - else - log_debug_errno(errno, "/boot/: %m"); - return (cache = false); -} - static int add_partition_xbootldr(DissectedPartition *p) { _cleanup_free_ char *options = NULL; int r; @@ -562,6 +535,33 @@ static int add_partition_xbootldr(DissectedPartition *p) { } #if ENABLE_EFI +static int slash_efi_in_fstab(void) { + static int cache = -1; + + if (cache >= 0) + return cache; + + cache = fstab_is_mount_point("/efi"); + if (cache < 0) + return log_error_errno(cache, "Failed to parse fstab: %m"); + return cache; +} + +static bool slash_boot_exists(void) { + static int cache = -1; + + if (cache >= 0) + return cache; + + if (access("/boot", F_OK) >= 0) + return (cache = true); + if (errno != ENOENT) + log_error_errno(errno, "Failed to determine whether /boot/ exists, assuming no: %m"); + else + log_debug_errno(errno, "/boot/: %m"); + return (cache = false); +} + static int add_partition_esp(DissectedPartition *p, bool has_xbootldr) { const char *esp_path = NULL, *id = NULL; _cleanup_free_ char *options = NULL; From 6425dec88b9dedf53d12a970339ab88f948c201a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 31 Jul 2023 14:12:36 +0200 Subject: [PATCH 2/2] tests: skip static asserts on old clang versions We declare clang >= 10 is supported. The workaround is easy enough, so let's just do that. Fixes #28598. With Debian clang version 11.0.1-2: [267/384] Compiling C object test-bitfield.p/src_test_test-bitfield.c.o FAILED: test-bitfield.p/src_test_test-bitfield.c.o clang -Itest-bitfield.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Warray-bounds -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=missing-declarations -Werror=missing-prototypes -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=undef -Wfloat-equal -Winit-self -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wunused-function -Wwrite-strings '-Wno-error=#warnings' -Wno-string-plus-int -fdiagnostics-show-option -fno-common -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Wno-typedef-redefinition -Wno-gnu-variable-sized-type-not-at-end -Werror=shadow -fno-strict-aliasing -fvisibility=hidden -fno-omit-frame-pointer -include config.h -DTEST_CODE=1 -MD -MQ test-bitfield.p/src_test_test-bitfield.c.o -MF test-bitfield.p/src_test_test-bitfield.c.o.d -o test-bitfield.p/src_test_test-bitfield.c.o -c ../src/test/test-bitfield.c ../src/test/test-bitfield.c:216:9: error: static_assert failed due to requirement '__builtin_constant_p(({ static_assert(sizeof(unsigned char) <= sizeof(unsigned long long), "sizeof(uint8_t) <= sizeof(unsigned long long)"); static_assert(__builtin_choose_expr(__builtin_constant_p(1), 1, 0) < (int)(sizeof(unsigned char) * 8), "__builtin_choose_expr(__builtin_constant_p(1), 1, 0) < (int)(sizeof(uint8_t) * 8)"); __builtin_choose_expr(__builtin_constant_p(1), ((unsigned char)1) << (1), ({ int __unique_prefix__i751 = (1); do { if ((__builtin_expect(!!(!(__unique_prefix__i751 < (int)sizeof(unsigned char) * 8)), 0))) log_assert_failed("UNIQ_T(_i, 751) < (int)sizeof(uint8_t) * 8", (&"../src/test/test-bitfield.c"[(sizeof ("..") - sizeof(const char)) + 1]), 216, __func__); } while (0); ((unsigned char)1) << __unique_prefix__i751; })); }))' "__builtin_constant_p(INDEX_TO_MASK(uint8_t, 1))" assert_cc(__builtin_constant_p(INDEX_TO_MASK(uint8_t, 1))); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/fundamental/macro-fundamental.h:109:25: note: expanded from macro 'assert_cc' ^ ~~~~ /usr/include/assert.h:143:24: note: expanded from macro 'static_assert' ^ ... --- src/test/test-bitfield.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/test-bitfield.c b/src/test/test-bitfield.c index 74ebd5cc48..0f29c5d8bf 100644 --- a/src/test/test-bitfield.c +++ b/src/test/test-bitfield.c @@ -213,6 +213,8 @@ TEST(bits) { assert_se(_u64 == u64); /* Verify these use cases are constant-folded. */ +#if !defined(__clang__) || (__clang_major__ >= 13) + /* Clang 11 doesn't grok those; skip them. */ assert_cc(__builtin_constant_p(INDEX_TO_MASK(uint8_t, 1))); assert_cc(__builtin_constant_p(INDEX_TO_MASK(uint16_t, 1))); assert_cc(__builtin_constant_p(INDEX_TO_MASK(uint32_t, 1))); @@ -222,6 +224,7 @@ TEST(bits) { assert_cc(__builtin_constant_p(BIT_SET((uint16_t)2, 1))); assert_cc(__builtin_constant_p(BIT_SET((uint32_t)2, 1))); assert_cc(__builtin_constant_p(BIT_SET((uint64_t)2, 1))); +#endif } DEFINE_TEST_MAIN(LOG_INFO);