Clang tidy headers (#37566)

This commit is contained in:
Daan De Meyer
2025-05-22 12:01:57 +02:00
committed by GitHub
20 changed files with 63 additions and 59 deletions

View File

@@ -2841,14 +2841,14 @@ alias_target('gensources', generated_sources)
clang_tidy = find_program('clang-tidy', required : false)
if meson.version().version_compare('>=1.4.0')
foreach source : sources
if fs.name(source).endswith('.h')
if not source.full_path().endswith('.c') and not source.full_path().endswith('.h')
continue
endif
inputs = [source]
header = source.full_path().replace('.c', '.h')
if fs.exists(header)
if fs.exists(header) and header != source.full_path()
inputs += header
endif

View File

@@ -10,8 +10,8 @@
static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
#include "af-from-name.h"
#include "af-to-name.h"
#include "af-from-name.inc"
#include "af-to-name.inc"
const char* af_to_name(int id) {

View File

@@ -12,8 +12,8 @@
static const struct arphrd_name* lookup_arphrd(register const char *str, register GPERF_LEN_TYPE len);
#include "arphrd-from-name.h"
#include "arphrd-to-name.h"
#include "arphrd-from-name.inc"
#include "arphrd-to-name.inc"
int arphrd_from_name(const char *name) {
const struct arphrd_name *sc;

View File

@@ -17,8 +17,8 @@
static const struct capability_name* lookup_capability(register const char *str, register GPERF_LEN_TYPE len);
#include "cap-from-name.h"
#include "cap-to-name.h"
#include "cap-from-name.inc"
#include "cap-to-name.inc"
const char* capability_to_name(int id) {
if (id < 0)

View File

@@ -10,10 +10,10 @@
static const struct errno_name* lookup_errno(register const char *str,
register GPERF_LEN_TYPE len);
#include "errno-from-name.h"
#include "errno-from-name.inc"
#if !HAVE_STRERRORNAME_NP
#include "errno-to-name.h"
#include "errno-to-name.inc"
const char* errno_to_name(int id) {

View File

@@ -6,7 +6,7 @@
const char* fs_type_to_string(statfs_f_type_t magic) {
switch (magic) {
#include "filesystem-switch-case.h"
#include "filesystem-switch-case.inc"
}
return NULL;
@@ -158,7 +158,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = {
.name = "@known",
.help = "All known filesystems declared in the kernel",
.value =
#include "filesystem-list.h"
#include "filesystem-list.inc"
},
};

View File

@@ -168,7 +168,7 @@ foreach item : [['af', af_list_txt, 'af', ''],
command : [generate_gperfs, item[2], item[3], '@INPUT@'],
capture : true)
fname = '@0@-from-name.h'.format(item[0])
fname = '@0@-from-name.inc'.format(item[0])
target1 = custom_target(
fname,
input : gperf_file,
@@ -181,7 +181,7 @@ foreach item : [['af', af_list_txt, 'af', ''],
'@INPUT@'],
capture : true)
fname = '@0@-to-name.h'.format(item[0])
fname = '@0@-to-name.inc'.format(item[0])
awkscript = '@0@-to-name.awk'.format(item[0])
target2 = custom_target(
fname,
@@ -266,8 +266,8 @@ filesystems_gperf_h = custom_target(
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
generate_filesystem_list = find_program('generate-filesystem-list.py')
fname = 'filesystem-list.h'
filesystem_list_h = custom_target(
fname = 'filesystem-list.inc'
filesystem_list_inc = custom_target(
fname,
input : 'filesystems-gperf.gperf',
output : fname,
@@ -275,18 +275,18 @@ filesystem_list_h = custom_target(
'@INPUT@'],
capture : true)
generate_filesystem_switch_case_h = find_program('generate-filesystem-switch-case.py')
fname = 'filesystem-switch-case.h'
filesystem_switch_case_h = custom_target(
generate_filesystem_switch_case_inc = find_program('generate-filesystem-switch-case.py')
fname = 'filesystem-switch-case.inc'
filesystem_switch_case_inc = custom_target(
fname,
input : 'filesystems-gperf.gperf',
output : 'filesystem-switch-case.h',
command : [generate_filesystem_switch_case_h,
output : fname,
command : [generate_filesystem_switch_case_inc,
'@INPUT@'],
capture : true)
generated_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h]
basic_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h]
generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
libbasic_static = static_library(
'basic',

View File

@@ -3,4 +3,4 @@
#include "audit-type.h"
#include "missing_audit.h"
#include "audit_type-to-name.h"
#include "audit_type-to-name.inc"

View File

@@ -27,8 +27,8 @@ audit_type_list_txt = custom_target(
capture : true)
audit_type_to_name = custom_target(
'audit_type-to-name.h',
'audit_type-to-name.inc',
input : ['audit_type-to-name.awk', audit_type_list_txt],
output : 'audit_type-to-name.h',
output : 'audit_type-to-name.inc',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)

View File

@@ -14,8 +14,8 @@ typedef const struct {
static const struct dns_type_name *
lookup_dns_type (register const char *str, register GPERF_LEN_TYPE len);
#include "dns_type-from-name.h"
#include "dns_type-to-name.h"
#include "dns_type-from-name.inc"
#include "dns_type-to-name.inc"
int dns_type_from_string(const char *s) {
const struct dns_type_name *sc;

View File

@@ -61,10 +61,10 @@ gperf_file = custom_target(
command : [generate_dns_type_gperf, 'dns_type', 'DNS_TYPE_', '@INPUT@'],
capture : true)
dns_type_from_name_h = custom_target(
'dns_type-from-name.h',
dns_type_from_name_inc = custom_target(
'dns_type-from-name.inc',
input : gperf_file,
output : 'dns_type-from-name.h',
output : 'dns_type-from-name.inc',
command : [gperf,
'-L', 'ANSI-C', '-t', '--ignore-case',
'-N', 'lookup_dns_type',
@@ -73,10 +73,10 @@ dns_type_from_name_h = custom_target(
'@INPUT@'],
capture : true)
dns_type_to_name_h = custom_target(
'dns_type-to-name.h',
dns_type_to_name_inc = custom_target(
'dns_type-to-name.inc',
input : ['dns_type-to-name.awk', dns_type_list_txt],
output : 'dns_type-to-name.h',
output : 'dns_type-to-name.inc',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true)
@@ -98,8 +98,8 @@ resolved_dns_delegate_gperf_c = custom_target(
output : 'resolved-dns-delegate-gperf.c',
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
generated_sources += [dns_type_from_name_h, dns_type_to_name_h, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c]
systemd_resolved_extract_sources += [dns_type_from_name_h, dns_type_to_name_h, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c]
generated_sources += [dns_type_from_name_inc, dns_type_to_name_inc, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c]
systemd_resolved_extract_sources += [dns_type_from_name_inc, dns_type_to_name_inc, resolved_gperf_c, resolved_dnssd_gperf_c, resolved_dns_delegate_gperf_c]
if conf.get('ENABLE_DNS_OVER_TLS') == 1
systemd_resolved_extract_sources += files(

View File

@@ -154,7 +154,7 @@ static const char* const netdev_feature_table[_NET_DEV_FEAT_MAX] = {
};
static const char* const ethtool_link_mode_bit_table[] = {
# include "ethtool-link-mode.h"
# include "ethtool-link-mode.inc"
};
/* Make sure the array is large enough to fit all bits */
assert_cc((ELEMENTSOF(ethtool_link_mode_bit_table)-1) / 32 < N_ADVERTISE);

View File

@@ -11,8 +11,8 @@
static const struct ip_protocol_name* lookup_ip_protocol(register const char *str, register GPERF_LEN_TYPE len);
#include "ip-protocol-from-name.h"
#include "ip-protocol-to-name.h"
#include "ip-protocol-from-name.inc"
#include "ip-protocol-to-name.inc"
const char* ip_protocol_to_name(int id) {

View File

@@ -227,8 +227,8 @@ if get_option('tests') != 'false'
endif
generate_syscall_list = find_program('generate-syscall-list.py')
fname = 'syscall-list.h'
syscall_list_h = custom_target(
fname = 'syscall-list.inc'
syscall_list_inc = custom_target(
fname,
input : syscall_list_txt,
output : fname,
@@ -236,7 +236,7 @@ syscall_list_h = custom_target(
'@INPUT@'],
capture : true)
generated_sources += syscall_list_h
generated_sources += syscall_list_inc
if conf.get('ENABLE_UTMP') == 1
shared_sources += files('utmp-wtmp.c')
@@ -244,7 +244,7 @@ endif
if conf.get('HAVE_SECCOMP') == 1
shared_sources += files('seccomp-util.c')
shared_sources += syscall_list_h
shared_sources += syscall_list_inc
endif
if conf.get('HAVE_LIBIPTC') == 1
@@ -282,7 +282,7 @@ gperf_file = custom_target(
command : [generate_gperfs, 'ip_protocol', 'IPPROTO_', '@INPUT@', '<netinet/in.h>'],
capture : true)
fname = 'ip-protocol-from-name.h'
fname = 'ip-protocol-from-name.inc'
target1 = custom_target(
fname,
input : gperf_file,
@@ -295,7 +295,7 @@ target1 = custom_target(
'@INPUT@'],
capture : true)
fname = 'ip-protocol-to-name.h'
fname = 'ip-protocol-to-name.inc'
awkscript = 'ip-protocol-to-name.awk'
target2 = custom_target(
fname,
@@ -307,16 +307,16 @@ target2 = custom_target(
generated_sources += [target1, target2]
shared_sources += [target1, target2]
fname = 'ethtool-link-mode.h'
ethtool_link_mode_h = custom_target(
fname = 'ethtool-link-mode.inc'
ethtool_link_mode_inc = custom_target(
fname,
input : ['ethtool-link-mode.py', '../basic/include/linux/ethtool.h'],
output : fname,
command : [python, '@INPUT0@', '--header', cpp, '@INPUT1@'],
capture : true)
generated_sources += ethtool_link_mode_h
shared_sources += ethtool_link_mode_h
generated_sources += ethtool_link_mode_inc
shared_sources += ethtool_link_mode_inc
sources += shared_sources
fname = 'ethtool-link-mode.xml'

View File

@@ -989,7 +989,7 @@ const SyscallFilterSet syscall_filter_sets[_SYSCALL_FILTER_SET_MAX] = {
.help = "All known syscalls declared in the kernel",
.value =
"@obsolete\0"
#include "syscall-list.h"
#include "syscall-list.inc"
},
};

View File

@@ -52,6 +52,9 @@ _not_installed_headers = [
'sd-resolve.h',
]
sources += systemd_headers
sources += files(_not_installed_headers)
install_headers(
systemd_headers,
'_sd-common.h',

View File

@@ -1,13 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "af-list.h"
#include "tests.h"
_unused_
static const struct af_name* lookup_af(register const char *str, register GPERF_LEN_TYPE len);
#include "af-from-name.h"
#include "af-list.h"
#include "af-to-name.h"
#include "af-from-name.inc"
#include "af-to-name.inc"
TEST(af_list) {
for (unsigned i = 0; i < ELEMENTSOF(af_names); i++) {

View File

@@ -1,9 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "errno-list.h"
#include "errno-to-name.h"
#include "tests.h"
#include "errno-to-name.inc"
TEST(errno_list) {
ASSERT_NULL(errno_names[0]);
ASSERT_NULL(errno_to_name(0));

View File

@@ -78,8 +78,8 @@ gperf_file = custom_target(
command : [generate_keyboard_keys_gperf, '@INPUT@'],
capture : true)
fname = 'keyboard-keys-from-name.h'
keyboard_keys_from_name_h = custom_target(
fname = 'keyboard-keys-from-name.inc'
keyboard_keys_from_name_inc = custom_target(
fname,
input : gperf_file,
output : fname,
@@ -91,7 +91,7 @@ keyboard_keys_from_name_h = custom_target(
'@INPUT@'],
capture : true)
generated_sources += keyboard_keys_from_name_h
generated_sources += keyboard_keys_from_name_inc
############################################################
@@ -151,7 +151,7 @@ udev_binaries_dict = [
'public' : true,
'sources' : udevadm_sources +
udevadm_extract_sources +
keyboard_keys_from_name_h,
keyboard_keys_from_name_inc,
'include_directories' : [
libexec_template['include_directories'],
include_directories('.', 'net'),

View File

@@ -14,7 +14,7 @@
#include "udev-builtin.h"
static const struct key_name *keyboard_lookup_key(const char *str, GPERF_LEN_TYPE len);
#include "keyboard-keys-from-name.h"
#include "keyboard-keys-from-name.inc"
static int install_force_release(sd_device *dev, const unsigned *release, unsigned release_count) {
sd_device *atkbd;