tree-wide: suppress misc-use-internal-linkage warnings
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.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
e65a6e26ad
commit
8903e6b5f7
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)};',
|
||||
)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user