clang-tidy fixes (#40947)

This commit is contained in:
Mike Yuan
2026-03-04 16:27:51 +01:00
committed by GitHub
34 changed files with 82 additions and 88 deletions
+2
View File
@@ -21,6 +21,8 @@ extern char *arg_esp_path;
extern char *arg_xbootldr_path;
extern bool arg_print_esp_path;
extern bool arg_print_dollar_boot_path;
extern bool arg_print_loader_path;
extern bool arg_print_stub_path;
extern unsigned arg_print_root_device;
extern int arg_touch_variables;
extern bool arg_install_random_seed;
+21 -21
View File
@@ -143,37 +143,37 @@ static int units_by_state_total_build_json(MetricFamilyContext *context, void *u
return 0;
}
const MetricFamily metric_family_table[] = {
static const MetricFamily metric_family_table[] = {
/* Keep metrics ordered alphabetically */
{
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "NRestarts",
.description = "Per unit metric: number of restarts",
.type = METRIC_FAMILY_TYPE_COUNTER,
.generate = nrestarts_build_json,
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "NRestarts",
.description = "Per unit metric: number of restarts",
.type = METRIC_FAMILY_TYPE_COUNTER,
.generate = nrestarts_build_json,
},
{
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitActiveState",
.description = "Per unit metric: active state",
.type = METRIC_FAMILY_TYPE_STRING,
.generate = unit_active_state_build_json,
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitActiveState",
.description = "Per unit metric: active state",
.type = METRIC_FAMILY_TYPE_STRING,
.generate = unit_active_state_build_json,
},
{
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitLoadState",
.description = "Per unit metric: load state",
.type = METRIC_FAMILY_TYPE_STRING,
.generate = unit_load_state_build_json,
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitLoadState",
.description = "Per unit metric: load state",
.type = METRIC_FAMILY_TYPE_STRING,
.generate = unit_load_state_build_json,
},
{
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitsByStateTotal",
.description = "Total number of units of different state",
.type = METRIC_FAMILY_TYPE_GAUGE,
.generate = units_by_state_total_build_json,
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitsByStateTotal",
.description = "Total number of units of different state",
.type = METRIC_FAMILY_TYPE_GAUGE,
.generate = units_by_state_total_build_json,
},
{
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitsByTypeTotal",
.description = "Total number of units of different types",
.type = METRIC_FAMILY_TYPE_GAUGE,
.generate = units_by_type_total_build_json,
.name = METRIC_IO_SYSTEMD_MANAGER_PREFIX "UnitsByTypeTotal",
.description = "Total number of units of different types",
.type = METRIC_FAMILY_TYPE_GAUGE,
.generate = units_by_type_total_build_json,
},
{}
};
+1 -1
View File
@@ -54,7 +54,7 @@ static uint32_t arg_tpm2_public_key_pcr_mask = 0;
static char *arg_tpm2_signature = NULL;
static char *arg_tpm2_pcrlock = NULL;
static char *arg_node = NULL;
PagerFlags arg_pager_flags = 0;
static PagerFlags arg_pager_flags = 0;
static int *arg_wipe_slots = NULL;
static size_t arg_n_wipe_slots = 0;
static WipeScope arg_wipe_slots_scope = WIPE_EXPLICIT;
+1 -1
View File
@@ -850,7 +850,7 @@ static int bus_home_node_enumerator(
return 1;
}
const sd_bus_vtable home_vtable[] = {
static const sd_bus_vtable home_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("UserName", "s",
+1 -1
View File
@@ -28,7 +28,7 @@
#include "strv.h"
#include "tmpfile-util.h"
const char * const catalog_file_dirs[] = {
static const char * const catalog_file_dirs[] = {
"/usr/local/lib/systemd/catalog/",
"/usr/lib/systemd/catalog/",
NULL
+1 -1
View File
@@ -443,7 +443,7 @@ static int image_node_enumerator(sd_bus *bus, const char *path, void *userdata,
return 1;
}
const sd_bus_vtable image_vtable[] = {
static const sd_bus_vtable image_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("Name", "s", NULL, offsetof(Image, name), 0),
SD_BUS_PROPERTY("Path", "s", NULL, offsetof(Image, path), 0),
+1 -1
View File
@@ -380,7 +380,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
r,
"Failed to check if machine '%s' is running in the root user namespace: %m",
m->name);
if (r != 0)
if (r > 0)
return sd_bus_error_set(
error,
SD_BUS_ERROR_ACCESS_DENIED,
+4 -3
View File
@@ -26,6 +26,7 @@
#include "machine.h"
#include "machine-dbus.h"
#include "machined.h"
#include "machined-dbus.h"
#include "namespace-util.h"
#include "operation.h"
#include "os-util.h"
@@ -1219,7 +1220,7 @@ static int method_map_to_machine_group(sd_bus_message *message, void *userdata,
return sd_bus_reply_method_return(message, "sou", machine->name, o, (uint32_t) converted);
}
const sd_bus_vtable manager_vtable[] = {
static const sd_bus_vtable manager_vtable[] = {
SD_BUS_VTABLE_START(0),
SD_BUS_PROPERTY("PoolPath", "s", property_get_pool_path, 0, 0),
@@ -1451,8 +1452,8 @@ const BusObjectImplementation manager_object = {
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
.vtables = BUS_VTABLES(manager_vtable),
.children = BUS_IMPLEMENTATIONS( &machine_object,
&image_object ),
.children = BUS_IMPLEMENTATIONS(&machine_object,
&image_object),
};
int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
+6
View File
@@ -0,0 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "machine-forward.h"
extern const BusObjectImplementation manager_object;
+1
View File
@@ -23,6 +23,7 @@
#include "hostname-util.h"
#include "machine.h"
#include "machined.h"
#include "machined-dbus.h"
#include "machined-varlink.h"
#include "main-func.h"
#include "mkdir-label.h"
-2
View File
@@ -42,8 +42,6 @@ typedef struct Manager {
int manager_add_machine(Manager *m, const char *name, Machine **ret);
int manager_get_machine_by_pidref(Manager *m, const PidRef *pidref, Machine **ret);
extern const BusObjectImplementation manager_object;
int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error);
int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error);
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error);
+1 -1
View File
@@ -40,7 +40,7 @@
#include "unit-name.h"
#include "user-util.h"
enum {
static enum {
ACTION_DEFAULT,
ACTION_MOUNT,
ACTION_AUTOMOUNT,
+1 -1
View File
@@ -162,7 +162,7 @@ DEFINE_HASH_OPS(
address_hash_func,
address_compare_func);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
address_section_hash_ops,
ConfigSection,
config_section_hash_func,
+1 -1
View File
@@ -234,7 +234,7 @@ DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(
route_compare_func,
route_unref);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
route_section_hash_ops,
ConfigSection,
config_section_hash_func,
+1 -1
View File
@@ -202,7 +202,7 @@ static char **arg_network_veth_extra = NULL;
static char *arg_network_bridge = NULL;
static char *arg_network_zone = NULL;
static char *arg_network_namespace_path = NULL;
struct ether_addr arg_network_provided_mac = {};
static struct ether_addr arg_network_provided_mac = {};
static PagerFlags arg_pager_flags = 0;
static unsigned long arg_personality = PERSONALITY_INVALID;
static char *arg_image = NULL;
+3 -6
View File
@@ -78,13 +78,10 @@ static void context_done(Context *context) {
}
DEFINE_TRIVIAL_CLEANUP_FUNC(LinkInfo*, link_info_free);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
link_info_hash_ops,
void,
trivial_hash_func,
trivial_compare_func,
LinkInfo,
link_info_free);
void, trivial_hash_func, trivial_compare_func,
LinkInfo, link_info_free);
static int metric_compare(sd_json_variant *const *a, sd_json_variant *const *b) {
const char *name_a, *name_b, *object_a, *object_b;
+1 -1
View File
@@ -146,7 +146,7 @@ static int stub_packet_compare_func(const DnsPacket *x, const DnsPacket *y) {
return memcmp(DNS_PACKET_HEADER(x), DNS_PACKET_HEADER(y), sizeof(DnsPacketHeader));
}
DEFINE_HASH_OPS(stub_packet_hash_ops, DnsPacket, stub_packet_hash_func, stub_packet_compare_func);
DEFINE_PRIVATE_HASH_OPS(stub_packet_hash_ops, DnsPacket, stub_packet_hash_func, stub_packet_compare_func);
static int reply_add_with_rrsig(
DnsAnswer **reply,
+1 -1
View File
@@ -328,7 +328,7 @@ static void manager_gc_hooks(Manager *m, usec_t seen_usec) {
}
}
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
hook_hash_ops,
char, string_hash_func, string_compare_func,
Hook, hook_unlink);
+1 -1
View File
@@ -56,7 +56,7 @@ struct acpi_fpdt_boot {
uint64_t startup_start;
uint64_t exit_services_entry;
uint64_t exit_services_exit;
} _packed;
} _packed_;
/* /dev/mem is deprecated on many systems, try using /sys/firmware/acpi/fpdt parsing instead.
* This code requires kernel version 5.12 on x86 based machines or 6.2 for arm64 */
+4 -3
View File
@@ -19,6 +19,10 @@
#define MODERN_LIBBPF 0
#endif
static void *bpf_dl = NULL;
static DLSYM_PROTOTYPE(libbpf_get_error) = NULL;
DLSYM_PROTOTYPE(bpf_link__destroy) = NULL;
DLSYM_PROTOTYPE(bpf_link__fd) = NULL;
DLSYM_PROTOTYPE(bpf_link__open) = NULL;
@@ -43,15 +47,12 @@ DLSYM_PROTOTYPE(bpf_program__attach) = NULL;
DLSYM_PROTOTYPE(bpf_program__attach_cgroup) = NULL;
DLSYM_PROTOTYPE(bpf_program__attach_lsm) = NULL;
DLSYM_PROTOTYPE(bpf_program__name) = NULL;
DLSYM_PROTOTYPE(libbpf_get_error) = NULL;
DLSYM_PROTOTYPE(libbpf_set_print) = NULL;
DLSYM_PROTOTYPE(ring_buffer__epoll_fd) = NULL;
DLSYM_PROTOTYPE(ring_buffer__free) = NULL;
DLSYM_PROTOTYPE(ring_buffer__new) = NULL;
DLSYM_PROTOTYPE(ring_buffer__poll) = NULL;
static void* bpf_dl = NULL;
/* new symbols available from libbpf 0.7.0 */
int (*sym_bpf_map_create)(enum bpf_map_type, const char *, __u32, __u32, __u32, const struct bpf_map_create_opts *);
struct bpf_map* (*sym_bpf_object__next_map)(const struct bpf_object *obj, const struct bpf_map *map);
+3 -6
View File
@@ -250,13 +250,10 @@ static AsyncPolkitQuery* async_polkit_query_free(AsyncPolkitQuery *q) {
DEFINE_PRIVATE_TRIVIAL_REF_UNREF_FUNC(AsyncPolkitQuery, async_polkit_query, async_polkit_query_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(AsyncPolkitQuery*, async_polkit_query_unref);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
async_polkit_query_hash_ops,
void,
trivial_hash_func,
trivial_compare_func,
AsyncPolkitQuery,
async_polkit_query_unref);
void, trivial_hash_func, trivial_compare_func,
AsyncPolkitQuery, async_polkit_query_unref);
static int async_polkit_defer(sd_event_source *s, void *userdata) {
AsyncPolkitQuery *q = ASSERT_PTR(userdata);
+3 -3
View File
@@ -1099,9 +1099,9 @@ static JsonData* json_data_free(JsonData *d) {
DEFINE_TRIVIAL_CLEANUP_FUNC(JsonData*, json_data_free);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(json_data_hash_ops_free,
char, string_hash_func, string_compare_func,
JsonData, json_data_free);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(json_data_hash_ops_free,
char, string_hash_func, string_compare_func,
JsonData, json_data_free);
static int update_json_data(
Hashmap *h,
+6 -6
View File
@@ -15,12 +15,12 @@
static void *passwdqc_dl = NULL;
DLSYM_PROTOTYPE(passwdqc_params_reset) = NULL;
DLSYM_PROTOTYPE(passwdqc_params_load) = NULL;
DLSYM_PROTOTYPE(passwdqc_params_parse) = NULL;
DLSYM_PROTOTYPE(passwdqc_params_free) = NULL;
DLSYM_PROTOTYPE(passwdqc_check) = NULL;
DLSYM_PROTOTYPE(passwdqc_random) = NULL;
static DLSYM_PROTOTYPE(passwdqc_params_reset) = NULL;
static DLSYM_PROTOTYPE(passwdqc_params_load) = NULL;
static DLSYM_PROTOTYPE(passwdqc_params_parse) = NULL;
static DLSYM_PROTOTYPE(passwdqc_params_free) = NULL;
static DLSYM_PROTOTYPE(passwdqc_check) = NULL;
static DLSYM_PROTOTYPE(passwdqc_random) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(passwdqc_params_t*, sym_passwdqc_params_free, passwdqc_params_freep, NULL);
+8 -8
View File
@@ -18,14 +18,14 @@
static void *pwquality_dl = NULL;
DLSYM_PROTOTYPE(pwquality_check) = NULL;
DLSYM_PROTOTYPE(pwquality_default_settings) = NULL;
DLSYM_PROTOTYPE(pwquality_free_settings) = NULL;
DLSYM_PROTOTYPE(pwquality_generate) = NULL;
DLSYM_PROTOTYPE(pwquality_get_str_value) = NULL;
DLSYM_PROTOTYPE(pwquality_read_config) = NULL;
DLSYM_PROTOTYPE(pwquality_set_int_value) = NULL;
DLSYM_PROTOTYPE(pwquality_strerror) = NULL;
static DLSYM_PROTOTYPE(pwquality_check) = NULL;
static DLSYM_PROTOTYPE(pwquality_default_settings) = NULL;
static DLSYM_PROTOTYPE(pwquality_free_settings) = NULL;
static DLSYM_PROTOTYPE(pwquality_generate) = NULL;
static DLSYM_PROTOTYPE(pwquality_get_str_value) = NULL;
static DLSYM_PROTOTYPE(pwquality_read_config) = NULL;
static DLSYM_PROTOTYPE(pwquality_set_int_value) = NULL;
static DLSYM_PROTOTYPE(pwquality_strerror) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pwquality_settings_t*, sym_pwquality_free_settings, pwquality_free_settingsp, NULL);
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "varlink-io.systemd.FactoryReset.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
-2
View File
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "bus-polkit.h"
#include "varlink-idl-common.h"
#include "varlink-io.systemd.Machine.h"
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "bus-polkit.h"
#include "varlink-io.systemd.MachineImage.h"
-2
View File
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "varlink-io.systemd.Metrics.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "varlink-io.systemd.MuteConsole.h"
static SD_VARLINK_DEFINE_METHOD_FULL(
-2
View File
@@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-varlink-idl.h"
#include "varlink-io.systemd.Repart.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
+1
View File
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink-idl-common.h"
#include "varlink-io.systemd.Unit.h"
/* CGroupContext */
static SD_VARLINK_DEFINE_STRUCT_TYPE(
+6 -4
View File
@@ -184,8 +184,9 @@ static Job *job_free(Job *j) {
}
DEFINE_TRIVIAL_CLEANUP_FUNC(Job*, job_free);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(job_hash_ops, uint64_t, uint64_hash_func, uint64_compare_func,
Job, job_free);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(job_hash_ops,
uint64_t, uint64_hash_func, uint64_compare_func,
Job, job_free);
static int job_new(JobType type, Target *t, sd_bus_message *msg, JobComplete complete_cb, Job **ret) {
_cleanup_(job_freep) Job *j = NULL;
@@ -728,8 +729,9 @@ static Target *target_free(Target *t) {
}
DEFINE_TRIVIAL_CLEANUP_FUNC(Target*, target_free);
DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(target_hash_ops, char, string_hash_func, string_compare_func,
Target, target_free);
DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(target_hash_ops,
char, string_hash_func, string_compare_func,
Target, target_free);
static int target_new(Manager *m, TargetClass class, const char *name, const char *path, Target **ret) {
_cleanup_(target_freep) Target *t = NULL;
+1 -1
View File
@@ -1109,7 +1109,7 @@ static const sd_bus_vtable timedate_vtable[] = {
SD_BUS_VTABLE_END,
};
const BusObjectImplementation manager_object = {
static const BusObjectImplementation manager_object = {
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
.vtables = BUS_VTABLES(timedate_vtable),
+1 -1
View File
@@ -140,7 +140,7 @@ static char *arg_background = NULL;
static bool arg_pass_ssh_key = true;
static char *arg_ssh_key_type = NULL;
static bool arg_discard_disk = true;
struct ether_addr arg_network_provided_mac = {};
static struct ether_addr arg_network_provided_mac = {};
static char **arg_smbios11 = NULL;
static uint64_t arg_grow_image = 0;
static char *arg_tpm_state_path = NULL;