Various cleanups (#37597)

This commit is contained in:
Daan De Meyer
2025-05-24 21:48:04 +02:00
committed by GitHub
9 changed files with 29 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
Diagnostics:
UnusedIncludes: None
UnusedIncludes: Strict

View File

@@ -71,7 +71,7 @@ jobs:
fi
- name: Configure meson
run: mkosi sandbox -- env CC=clang CXX=clang++ meson setup build
run: mkosi sandbox -- env CC=clang CXX=clang++ meson setup -Dlocalegen-path=/usr/bin/locale-gen -Dcompat-mutable-uid-boundaries=true build
- name: Run clang-tidy
run: mkosi sandbox -- meson test -C build --suite=clang-tidy --print-errorlogs --no-stdsplit

View File

@@ -2841,6 +2841,10 @@ 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 systemd_headers.contains(source)
continue
endif
if not source.full_path().endswith('.c') and not source.full_path().endswith('.h')
continue
endif
@@ -2848,7 +2852,7 @@ if meson.version().version_compare('>=1.4.0')
inputs = [source]
header = source.full_path().replace('.c', '.h')
if fs.exists(header) and header != source.full_path()
if fs.exists(header) and header != source.full_path() and header != libudev_h_path
inputs += header
endif

View File

@@ -6,6 +6,8 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton

View File

@@ -6,6 +6,8 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton

View File

@@ -6,6 +6,8 @@
* fine given that LGPL-2.1-or-later downgrades to GPL if needed.
*/
#include "bpf-dlopen.h"
/* libbpf is used via dlopen(), so rename symbols */
#define bpf_object__open_skeleton sym_bpf_object__open_skeleton
#define bpf_object__load_skeleton sym_bpf_object__load_skeleton

View File

@@ -2,7 +2,6 @@
#pragma once
#if !SD_BOOT
#include <stdlib.h>
#include <sys/uio.h>
#endif
@@ -15,10 +14,6 @@ struct iovec {
void *iov_base;
size_t iov_len;
};
DISABLE_WARNING_REDUNDANT_DECLS;
void free(void *p);
REENABLE_WARNING;
#endif
/* This accepts both const and non-const pointers */

View File

@@ -396,6 +396,10 @@ assert_cc(sizeof(long long) == sizeof(intmax_t));
*/
#define STRLEN(x) (sizeof(""x"") - sizeof(typeof(x[0])))
DISABLE_WARNING_REDUNDANT_DECLS;
void free(void *p);
REENABLE_WARNING;
#define mfree(memory) \
({ \
free(memory); \

View File

@@ -19,7 +19,9 @@ def process_sym_file(file: IO[str]) -> None:
print(f' {{ "{m[1]}", {m[1]} }},')
def process_header_file(file: IO[str]) -> None:
def process_header_file(file: IO[str]) -> str:
text = ''
for line in file:
if (
line.startswith('#')
@@ -43,22 +45,24 @@ def process_header_file(file: IO[str]) -> None:
# Functions
m = re.search(r'^(\S+\s+)+\**(\w+)\s*\(', line)
if m:
print(f' {{ "{m[2]}", {m[2]} }},')
text += f' {{ "{m[2]}", {m[2]} }},\n'
continue
# Variables
m = re.search(r'^extern\s', line)
if m:
n = line.split()[-1].rstrip(';')
print(f' {{ "{n}", &{n} }},')
text += f' {{ "{n}", &{n} }},\n'
continue
# Functions defined by macro
m = re.search(r'_SD_DEFINE_POINTER_CLEANUP_FUNC\(\w+,\s*(\w+)\)', line)
if m:
print(f' {{ "{m[1]}", {m[1]} }},')
text += f' {{ "{m[1]}", {m[1]} }},\n'
continue
return text
def process_source_file(file: IO[str]) -> None:
for line in file:
@@ -107,7 +111,9 @@ print("""/* SPDX-License-Identifier: LGPL-2.1-or-later */
""")
for header in sys.argv[3:]:
print('#include "{}"'.format(header.split('/')[-1]))
with open(header, 'r') as f:
if process_header_file(f):
print('#include "{}"'.format(header.split('/')[-1]))
print("""
/* We want to check deprecated symbols too, without complaining */
@@ -129,7 +135,7 @@ print(""" {}
for header in sys.argv[3:]:
with open(header, 'r') as f:
process_header_file(f)
print(process_header_file(f), end='')
print(""" {}
}, symbols_from_source[] = {""")