]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: suppress misc-use-internal-linkage warnings
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 4 Mar 2026 21:48:25 +0000 (06:48 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 5 Mar 2026 19:23:24 +0000 (20:23 +0100)
Suppress warnings like the following from clang tidy:
```
../src/boot/addon.c:11:19: error: function 'efi_main' can be made static to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
   11 | EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table);
      |                   ^
```

Some warnings are suppressed simply by setting comments to ignore the warning,
some are by making global variables static, or include a suitable header.

14 files changed:
src/analyze/test-verify.c
src/basic/compress.c
src/boot/addon.c
src/boot/boot.c
src/boot/efi-log.c
src/boot/efi-string.c
src/boot/generate-hwids-section.py
src/boot/stub.c
src/libsystemd-network/test-dhcp-client.c
src/libsystemd/sd-bus/test-bus-error.c
src/test/test-chid.c
src/test/test-exec-util.c
src/test/test-hashmap.c
src/test/test-load-fragment.c

index 8355ae6a807f5a78d16e7a3fd9ada128da4ebfbc..048d866dbe73c26b2ade6faaf97887fb637648f2 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "analyze.h"
 #include "analyze-verify-util.h"
 #include "execute.h"
 #include "tests.h"
index 82d856aa06783d689a5f7b018d43f9fcbdfa113c..c10448938e071c907eb6a6135033eab3a464c115 100644 (file)
@@ -46,10 +46,12 @@ static DLSYM_PROTOTYPE(LZ4F_freeDecompressionContext) = NULL;
 static DLSYM_PROTOTYPE(LZ4F_isError) = NULL;
 static DLSYM_PROTOTYPE(LZ4_compress_HC) = NULL;
 /* These are used in test-compress.c so we don't make them static. */
+// NOLINTBEGIN(misc-use-internal-linkage)
 DLSYM_PROTOTYPE(LZ4_compress_default) = NULL;
 DLSYM_PROTOTYPE(LZ4_decompress_safe) = NULL;
 DLSYM_PROTOTYPE(LZ4_decompress_safe_partial) = NULL;
 DLSYM_PROTOTYPE(LZ4_versionNumber) = NULL;
+// NOLINTEND(misc-use-internal-linkage)
 
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(LZ4F_compressionContext_t, sym_LZ4F_freeCompressionContext, LZ4F_freeCompressionContextp, NULL);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(LZ4F_decompressionContext_t, sym_LZ4F_freeDecompressionContext, LZ4F_freeDecompressionContextp, NULL);
index 95b29daf5514a5236fd44ec2bb31cd762c74fe9c..17a361436127d0a30316ccf1e646e510e82be1bc 100644 (file)
@@ -8,6 +8,7 @@ DECLARE_NOALLOC_SECTION(".sdmagic", "#### LoaderInfo: systemd-addon " GIT_VERSIO
 
 /* This is intended to carry data, not to be executed */
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table);
 EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) {
         return EFI_UNSUPPORTED;
index cdf36b95203057f1a91d188caed845f8bf322cfe..db5cfd989df23064ef680d5cb80b70ea5e626616 100644 (file)
@@ -3255,4 +3255,5 @@ static EFI_STATUS run(EFI_HANDLE image) {
         }
 }
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 DEFINE_EFI_MAIN_FUNCTION(run, "systemd-boot", /* wait_for_debugger= */ false);
index 3cecc7be06ae675eced74f6c06adc8f0722e9a5e..ed0a2746933e04295c8cfbb52af9fbb5d4912b5a 100644 (file)
@@ -132,6 +132,7 @@ void log_wait(void) {
         log_count = 0;
 }
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 _used_ intptr_t __stack_chk_guard = (intptr_t) 0x70f6967de78acae3;
 
 /* We can only set a random stack canary if this function attribute is available,
@@ -147,8 +148,10 @@ void __stack_chk_guard_init(void) {
 }
 #endif
 
+// NOLINTBEGIN(misc-use-internal-linkage)
 _used_ _noreturn_ void __stack_chk_fail(void);
 _used_ _noreturn_ void __stack_chk_fail_local(void);
+// NOLINTEND(misc-use-internal-linkage)
 void __stack_chk_fail(void) {
         panic(u"systemd-boot: Stack check failed, halting.");
 }
@@ -157,6 +160,7 @@ void __stack_chk_fail_local(void) {
 }
 
 /* Called by libgcc for some fatal errors like integer overflow with -ftrapv. */
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 _used_ _noreturn_ void abort(void);
 void abort(void) {
         panic(u"systemd-boot: Unknown error, halting.");
@@ -164,8 +168,10 @@ void abort(void) {
 
 #if defined(__ARM_EABI__)
 /* These override the (weak) div0 handlers from libgcc as they would otherwise call raise() instead. */
+// NOLINTBEGIN(misc-use-internal-linkage)
 _used_ _noreturn_ int __aeabi_idiv0(int return_value);
 _used_ _noreturn_ long long __aeabi_ldiv0(long long return_value);
+// NOLINTEND(misc-use-internal-linkage)
 
 int __aeabi_idiv0(int return_value) {
         panic(u"systemd-boot: Division by zero, halting.");
index cde10d0abd4376c22d12edf66a0f903ca93c5f3e..0f8986b5984b96098bce3102f819f2c4f7066cdb 100644 (file)
@@ -1050,10 +1050,12 @@ char16_t *xvasprintf_status(EFI_STATUS status, const char *format, va_list ap) {
 #  undef memcmp
 #  undef memcpy
 #  undef memset
+// NOLINTBEGIN(misc-use-internal-linkage)
 _used_ void *memchr(const void *p, int c, size_t n);
 _used_ int memcmp(const void *p1, const void *p2, size_t n);
 _used_ void *memcpy(void * restrict dest, const void * restrict src, size_t n);
 _used_ void *memset(void *p, int c, size_t n);
+// NOLINTEND(misc-use-internal-linkage)
 #else
 /* And for userspace unit testing we need to give them an efi_ prefix. */
 #  undef memchr
index 621183c20fba0afc905e8e2bb8b698996ce5a23b..cfe6aea739aa347d42d8ad0ddb98f3c4c08e48a3 100755 (executable)
@@ -20,6 +20,7 @@ print(
 #include <stddef.h>
 #include <stdint.h>
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 const uint8_t hwids_section_data[] = {
     """,
     end='',
@@ -34,6 +35,8 @@ for i, b in enumerate(hwids):
 
 print(
     """};
+
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 const size_t hwids_section_len =""",
     f'{len(hwids)};',
 )
index 65950262c69d5beaf7d0a29245a625e9dfbb2486..90f28a8ae32f75371bd5ae12f439f85efbb1eb53 100644 (file)
@@ -1325,4 +1325,5 @@ static EFI_STATUS run(EFI_HANDLE image) {
         return err;
 }
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 DEFINE_EFI_MAIN_FUNCTION(run, "systemd-stub", /* wait_for_debugger= */ false);
index 35cfcec6aca04cd2405a2c2986816062eb042042..7a8b149e2036346a2726dd313bcfec314128134c 100644 (file)
@@ -41,7 +41,7 @@ struct bootp_addr_data {
         int netmask_offset;
         int ip_offset;
 };
-struct bootp_addr_data *bootp_test_context;
+static struct bootp_addr_data *bootp_test_context;
 
 static bool verbose = true;
 static int test_fd[2];
index db41141811f84775faa34b1170b78fa4378da543..3f89a907eb654f6c0a861dafaf1892c7bbcccbbf 100644 (file)
@@ -154,13 +154,13 @@ TEST(errno_mapping_standard) {
         assert_se(sd_bus_error_set(NULL, "System.Error.WHATSIT", NULL) == -EIO);
 }
 
-BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map test_errors[] = {
+BUS_ERROR_MAP_ELF_REGISTER static const sd_bus_error_map test_errors[] = {
         SD_BUS_ERROR_MAP("org.freedesktop.custom-dbus-error", 5),
         SD_BUS_ERROR_MAP("org.freedesktop.custom-dbus-error-2", 52),
         SD_BUS_ERROR_MAP_END
 };
 
-BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map test_errors2[] = {
+BUS_ERROR_MAP_ELF_REGISTER static const sd_bus_error_map test_errors2[] = {
         SD_BUS_ERROR_MAP("org.freedesktop.custom-dbus-error-3", 33),
         SD_BUS_ERROR_MAP("org.freedesktop.custom-dbus-error-4", 44),
         SD_BUS_ERROR_MAP("org.freedesktop.custom-dbus-error-33", 333),
index 564b09c183e7e1d5a7657c9a7480bc594d284056..86b748016aba0f9d36abc4a3976fad83b8b22912 100644 (file)
@@ -3,7 +3,7 @@
 #include "chid-fundamental.h"
 #include "tests.h"
 
-const char16_t *const test_fields[_CHID_SMBIOS_FIELDS_MAX] = {
+static const char16_t *const test_fields[_CHID_SMBIOS_FIELDS_MAX] = {
         [CHID_SMBIOS_MANUFACTURER]           = u"Micro-Star International Co., Ltd.",
         [CHID_SMBIOS_PRODUCT_NAME]           = u"MS-7D70",
         [CHID_SMBIOS_PRODUCT_SKU]            = u"To be filled by O.E.M.",
index 7c3b872c10dfd5308103acfadffdcd398c9b79cc..886d771fb5e0176fa4ff6b22bf14eb3184b2db6d 100644 (file)
@@ -231,7 +231,7 @@ static int gather_stdout_three(int fd, void *arg) {
         return 0;
 }
 
-const gather_stdout_callback_t gather_stdouts[] = {
+static const gather_stdout_callback_t gather_stdouts[] = {
         gather_stdout_one,
         gather_stdout_two,
         gather_stdout_three,
index 7f25ad101141c2c253475b753994cc55314d5731..4029d4a478fd24c986d1e3a88f8da424ad12da54 100644 (file)
@@ -3,14 +3,17 @@
 #include "hashmap.h"
 #include "tests.h"
 
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 unsigned custom_counter = 0;
 static void custom_destruct(void* p) {
         custom_counter--;
         free(p);
 }
 
+// NOLINTBEGIN(misc-use-internal-linkage)
 DEFINE_HASH_OPS_FULL(boring_hash_ops, char, string_hash_func, string_compare_func, free, char, free);
 DEFINE_HASH_OPS_FULL(custom_hash_ops, char, string_hash_func, string_compare_func, custom_destruct, char, custom_destruct);
+// NOLINTEND(misc-use-internal-linkage)
 
 TEST(ordered_hashmap_next) {
         _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
@@ -154,6 +157,7 @@ TEST(hashmap_put_strdup_null) {
  * they don't apply to ordered hashmaps. */
 
 /* This variable allows us to assert that the tests from different compilation units were actually run. */
+// NOLINTNEXTLINE(misc-use-internal-linkage)
 int n_extern_tests_run = 0;
 
 static int intro(void) {
index 892e471d8ab0cc10b00cda7cab4ebd53adb0af23..69d2d05b765c747df77cdadcc1e629bc4664f7c5 100644 (file)
@@ -37,7 +37,7 @@ static char *runtime_dir = NULL;
 STATIC_DESTRUCTOR_REGISTER(runtime_dir, rm_rf_physical_and_freep);
 
 /* For testing type compatibility. */
-_unused_ ConfigPerfItemLookup unused_lookup = load_fragment_gperf_lookup;
+_unused_ static ConfigPerfItemLookup unused_lookup = load_fragment_gperf_lookup;
 
 TEST_RET(unit_file_get_list) {
         int r;