mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
Merge pull request #18616 from keszybz/argv-fuzzer-quick-fix
fuzz-systemctl-parse-argv: avoid "leak" of bus object
This commit is contained in:
commit
0addd9ba9c
@ -92,7 +92,7 @@ static usec_t arg_base_time = USEC_INFINITY;
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_dot_from_patterns, strv_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_dot_to_patterns, strv_freep);
|
||||
|
||||
struct boot_times {
|
||||
typedef struct BootTimes {
|
||||
usec_t firmware_time;
|
||||
usec_t loader_time;
|
||||
usec_t kernel_time;
|
||||
@ -124,9 +124,9 @@ struct boot_times {
|
||||
* (so it is stored here for reference).
|
||||
*/
|
||||
usec_t reverse_offset;
|
||||
};
|
||||
} BootTimes;
|
||||
|
||||
struct unit_times {
|
||||
typedef struct UnitTimes {
|
||||
bool has_data;
|
||||
char *name;
|
||||
usec_t activating;
|
||||
@ -134,9 +134,9 @@ struct unit_times {
|
||||
usec_t deactivated;
|
||||
usec_t deactivating;
|
||||
usec_t time;
|
||||
};
|
||||
} UnitTimes;
|
||||
|
||||
struct host_info {
|
||||
typedef struct HostInfo {
|
||||
char *hostname;
|
||||
char *kernel_name;
|
||||
char *kernel_release;
|
||||
@ -144,7 +144,7 @@ struct host_info {
|
||||
char *os_pretty_name;
|
||||
char *virtualization;
|
||||
char *architecture;
|
||||
};
|
||||
} HostInfo;
|
||||
|
||||
static int acquire_bus(sd_bus **bus, bool *use_full_bus) {
|
||||
bool user = arg_scope != UNIT_FILE_SYSTEM;
|
||||
@ -209,19 +209,16 @@ static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int compare_unit_start(const struct unit_times *a, const struct unit_times *b) {
|
||||
static int compare_unit_start(const UnitTimes *a, const UnitTimes *b) {
|
||||
return CMP(a->activating, b->activating);
|
||||
}
|
||||
|
||||
static void unit_times_free(struct unit_times *t) {
|
||||
struct unit_times *p;
|
||||
|
||||
for (p = t; p->has_data; p++)
|
||||
static UnitTimes* unit_times_free_array(UnitTimes *t) {
|
||||
for (UnitTimes *p = t; p && p->has_data; p++)
|
||||
free(p->name);
|
||||
free(t);
|
||||
return mfree(t);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct unit_times *, unit_times_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitTimes*, unit_times_free_array);
|
||||
|
||||
static void subtract_timestamp(usec_t *a, usec_t b) {
|
||||
assert(a);
|
||||
@ -232,30 +229,30 @@ static void subtract_timestamp(usec_t *a, usec_t b) {
|
||||
}
|
||||
}
|
||||
|
||||
static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) {
|
||||
static int acquire_boot_times(sd_bus *bus, BootTimes **bt) {
|
||||
static const struct bus_properties_map property_map[] = {
|
||||
{ "FirmwareTimestampMonotonic", "t", NULL, offsetof(struct boot_times, firmware_time) },
|
||||
{ "LoaderTimestampMonotonic", "t", NULL, offsetof(struct boot_times, loader_time) },
|
||||
{ "KernelTimestamp", "t", NULL, offsetof(struct boot_times, kernel_time) },
|
||||
{ "InitRDTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_time) },
|
||||
{ "UserspaceTimestampMonotonic", "t", NULL, offsetof(struct boot_times, userspace_time) },
|
||||
{ "FinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, finish_time) },
|
||||
{ "SecurityStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, security_start_time) },
|
||||
{ "SecurityFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, security_finish_time) },
|
||||
{ "GeneratorsStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, generators_start_time) },
|
||||
{ "GeneratorsFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, generators_finish_time) },
|
||||
{ "UnitsLoadStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, unitsload_start_time) },
|
||||
{ "UnitsLoadFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, unitsload_finish_time) },
|
||||
{ "InitRDSecurityStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_security_start_time) },
|
||||
{ "InitRDSecurityFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_security_finish_time) },
|
||||
{ "InitRDGeneratorsStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_generators_start_time) },
|
||||
{ "InitRDGeneratorsFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_generators_finish_time) },
|
||||
{ "InitRDUnitsLoadStartTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_unitsload_start_time) },
|
||||
{ "InitRDUnitsLoadFinishTimestampMonotonic", "t", NULL, offsetof(struct boot_times, initrd_unitsload_finish_time) },
|
||||
{ "FirmwareTimestampMonotonic", "t", NULL, offsetof(BootTimes, firmware_time) },
|
||||
{ "LoaderTimestampMonotonic", "t", NULL, offsetof(BootTimes, loader_time) },
|
||||
{ "KernelTimestamp", "t", NULL, offsetof(BootTimes, kernel_time) },
|
||||
{ "InitRDTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_time) },
|
||||
{ "UserspaceTimestampMonotonic", "t", NULL, offsetof(BootTimes, userspace_time) },
|
||||
{ "FinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, finish_time) },
|
||||
{ "SecurityStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, security_start_time) },
|
||||
{ "SecurityFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, security_finish_time) },
|
||||
{ "GeneratorsStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, generators_start_time) },
|
||||
{ "GeneratorsFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, generators_finish_time) },
|
||||
{ "UnitsLoadStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, unitsload_start_time) },
|
||||
{ "UnitsLoadFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, unitsload_finish_time) },
|
||||
{ "InitRDSecurityStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_security_start_time) },
|
||||
{ "InitRDSecurityFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_security_finish_time) },
|
||||
{ "InitRDGeneratorsStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_generators_start_time) },
|
||||
{ "InitRDGeneratorsFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_generators_finish_time) },
|
||||
{ "InitRDUnitsLoadStartTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_unitsload_start_time) },
|
||||
{ "InitRDUnitsLoadFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_unitsload_finish_time) },
|
||||
{},
|
||||
};
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
static struct boot_times times;
|
||||
static BootTimes times;
|
||||
static bool cached = false;
|
||||
int r;
|
||||
|
||||
@ -293,7 +290,7 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) {
|
||||
} else {
|
||||
/*
|
||||
* User-instance-specific or container-system-specific timestamps processing
|
||||
* (see comment to reverse_offset in struct boot_times).
|
||||
* (see comment to reverse_offset in BootTimes).
|
||||
*/
|
||||
times.reverse_offset = times.userspace_time;
|
||||
|
||||
@ -316,9 +313,9 @@ finish:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_host_info(struct host_info *hi) {
|
||||
static HostInfo* free_host_info(HostInfo *hi) {
|
||||
if (!hi)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(hi->hostname);
|
||||
free(hi->kernel_name);
|
||||
@ -327,23 +324,23 @@ static void free_host_info(struct host_info *hi) {
|
||||
free(hi->os_pretty_name);
|
||||
free(hi->virtualization);
|
||||
free(hi->architecture);
|
||||
free(hi);
|
||||
return mfree(hi);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct host_info *, free_host_info);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(HostInfo *, free_host_info);
|
||||
|
||||
static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
|
||||
static int acquire_time_data(sd_bus *bus, UnitTimes **out) {
|
||||
static const struct bus_properties_map property_map[] = {
|
||||
{ "InactiveExitTimestampMonotonic", "t", NULL, offsetof(struct unit_times, activating) },
|
||||
{ "ActiveEnterTimestampMonotonic", "t", NULL, offsetof(struct unit_times, activated) },
|
||||
{ "ActiveExitTimestampMonotonic", "t", NULL, offsetof(struct unit_times, deactivating) },
|
||||
{ "InactiveEnterTimestampMonotonic", "t", NULL, offsetof(struct unit_times, deactivated) },
|
||||
{ "InactiveExitTimestampMonotonic", "t", NULL, offsetof(UnitTimes, activating) },
|
||||
{ "ActiveEnterTimestampMonotonic", "t", NULL, offsetof(UnitTimes, activated) },
|
||||
{ "ActiveExitTimestampMonotonic", "t", NULL, offsetof(UnitTimes, deactivating) },
|
||||
{ "InactiveEnterTimestampMonotonic", "t", NULL, offsetof(UnitTimes, deactivated) },
|
||||
{},
|
||||
};
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(unit_times_freep) struct unit_times *unit_times = NULL;
|
||||
struct boot_times *boot_times = NULL;
|
||||
_cleanup_(unit_times_free_arrayp) UnitTimes *unit_times = NULL;
|
||||
BootTimes *boot_times = NULL;
|
||||
size_t allocated = 0, c = 0;
|
||||
UnitInfo u;
|
||||
int r;
|
||||
@ -361,7 +358,7 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
while ((r = bus_parse_unit_info(reply, &u)) > 0) {
|
||||
struct unit_times *t;
|
||||
UnitTimes *t;
|
||||
|
||||
if (!GREEDY_REALLOC(unit_times, allocated, c + 2))
|
||||
return log_oom();
|
||||
@ -414,28 +411,28 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
|
||||
return c;
|
||||
}
|
||||
|
||||
static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
|
||||
static int acquire_host_info(sd_bus *bus, HostInfo **hi) {
|
||||
static const struct bus_properties_map hostname_map[] = {
|
||||
{ "Hostname", "s", NULL, offsetof(struct host_info, hostname) },
|
||||
{ "KernelName", "s", NULL, offsetof(struct host_info, kernel_name) },
|
||||
{ "KernelRelease", "s", NULL, offsetof(struct host_info, kernel_release) },
|
||||
{ "KernelVersion", "s", NULL, offsetof(struct host_info, kernel_version) },
|
||||
{ "OperatingSystemPrettyName", "s", NULL, offsetof(struct host_info, os_pretty_name) },
|
||||
{ "Hostname", "s", NULL, offsetof(HostInfo, hostname) },
|
||||
{ "KernelName", "s", NULL, offsetof(HostInfo, kernel_name) },
|
||||
{ "KernelRelease", "s", NULL, offsetof(HostInfo, kernel_release) },
|
||||
{ "KernelVersion", "s", NULL, offsetof(HostInfo, kernel_version) },
|
||||
{ "OperatingSystemPrettyName", "s", NULL, offsetof(HostInfo, os_pretty_name) },
|
||||
{}
|
||||
};
|
||||
|
||||
static const struct bus_properties_map manager_map[] = {
|
||||
{ "Virtualization", "s", NULL, offsetof(struct host_info, virtualization) },
|
||||
{ "Architecture", "s", NULL, offsetof(struct host_info, architecture) },
|
||||
{ "Virtualization", "s", NULL, offsetof(HostInfo, virtualization) },
|
||||
{ "Architecture", "s", NULL, offsetof(HostInfo, architecture) },
|
||||
{}
|
||||
};
|
||||
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *system_bus = NULL;
|
||||
_cleanup_(free_host_infop) struct host_info *host;
|
||||
_cleanup_(free_host_infop) HostInfo *host = NULL;
|
||||
int r;
|
||||
|
||||
host = new0(struct host_info, 1);
|
||||
host = new0(HostInfo, 1);
|
||||
if (!host)
|
||||
return log_oom();
|
||||
|
||||
@ -482,7 +479,7 @@ manager:
|
||||
|
||||
static int pretty_boot_time(sd_bus *bus, char **_buf) {
|
||||
char ts[FORMAT_TIMESPAN_MAX];
|
||||
struct boot_times *t;
|
||||
BootTimes *t;
|
||||
static char buf[4096];
|
||||
size_t size;
|
||||
char *ptr;
|
||||
@ -559,14 +556,12 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
|
||||
}
|
||||
|
||||
static void svg_graph_box(double height, double begin, double end) {
|
||||
long long i;
|
||||
|
||||
/* outside box, fill */
|
||||
svg("<rect class=\"box\" x=\"0\" y=\"0\" width=\"%.03f\" height=\"%.03f\" />\n",
|
||||
SCALE_X * (end - begin),
|
||||
SCALE_Y * height);
|
||||
|
||||
for (i = ((long long) (begin / 100000)) * 100000; i <= end; i += 100000) {
|
||||
for (long long i = ((long long) (begin / 100000)) * 100000; i <= end; i += 100000) {
|
||||
/* lines for each second */
|
||||
if (i % 5000000 == 0)
|
||||
svg(" <line class=\"sec5\" x1=\"%.03f\" y1=\"0\" x2=\"%.03f\" y2=\"%.03f\" />\n"
|
||||
@ -594,7 +589,7 @@ static void svg_graph_box(double height, double begin, double end) {
|
||||
}
|
||||
}
|
||||
|
||||
static int plot_unit_times(struct unit_times *u, double width, int y) {
|
||||
static int plot_unit_times(UnitTimes *u, double width, int y) {
|
||||
char ts[FORMAT_TIMESPAN_MAX];
|
||||
bool b;
|
||||
|
||||
@ -617,13 +612,13 @@ static int plot_unit_times(struct unit_times *u, double width, int y) {
|
||||
}
|
||||
|
||||
static int analyze_plot(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(free_host_infop) struct host_info *host = NULL;
|
||||
_cleanup_(free_host_infop) HostInfo *host = NULL;
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
_cleanup_(unit_times_freep) struct unit_times *times = NULL;
|
||||
_cleanup_(unit_times_free_arrayp) UnitTimes *times = NULL;
|
||||
_cleanup_free_ char *pretty_times = NULL;
|
||||
bool use_full_bus = arg_scope == UNIT_FILE_SYSTEM;
|
||||
struct boot_times *boot;
|
||||
struct unit_times *u;
|
||||
BootTimes *boot;
|
||||
UnitTimes *u;
|
||||
int n, m = 1, y = 0, r;
|
||||
double width;
|
||||
|
||||
@ -837,13 +832,12 @@ static int list_dependencies_print(
|
||||
unsigned level,
|
||||
unsigned branches,
|
||||
bool last,
|
||||
struct unit_times *times,
|
||||
struct boot_times *boot) {
|
||||
UnitTimes *times,
|
||||
BootTimes *boot) {
|
||||
|
||||
unsigned i;
|
||||
char ts[FORMAT_TIMESPAN_MAX], ts2[FORMAT_TIMESPAN_MAX];
|
||||
|
||||
for (i = level; i != 0; i--)
|
||||
for (unsigned i = level; i != 0; i--)
|
||||
printf("%s", special_glyph(branches & (1 << (i-1)) ? SPECIAL_GLYPH_TREE_VERTICAL : SPECIAL_GLYPH_TREE_SPACE));
|
||||
|
||||
printf("%s", special_glyph(last ? SPECIAL_GLYPH_TREE_RIGHT : SPECIAL_GLYPH_TREE_BRANCH));
|
||||
@ -882,7 +876,7 @@ static Hashmap *unit_times_hashmap;
|
||||
|
||||
static int list_dependencies_compare(char *const *a, char *const *b) {
|
||||
usec_t usa = 0, usb = 0;
|
||||
struct unit_times *times;
|
||||
UnitTimes *times;
|
||||
|
||||
times = hashmap_get(unit_times_hashmap, *a);
|
||||
if (times)
|
||||
@ -894,7 +888,7 @@ static int list_dependencies_compare(char *const *a, char *const *b) {
|
||||
return CMP(usb, usa);
|
||||
}
|
||||
|
||||
static bool times_in_range(const struct unit_times *times, const struct boot_times *boot) {
|
||||
static bool times_in_range(const UnitTimes *times, const BootTimes *boot) {
|
||||
return times && times->activated > 0 && times->activated <= boot->finish_time;
|
||||
}
|
||||
|
||||
@ -904,8 +898,8 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned level,
|
||||
int r;
|
||||
usec_t service_longest = 0;
|
||||
int to_print = 0;
|
||||
struct unit_times *times;
|
||||
struct boot_times *boot;
|
||||
UnitTimes *times;
|
||||
BootTimes *boot;
|
||||
|
||||
if (strv_extend(units, name))
|
||||
return log_oom();
|
||||
@ -970,13 +964,13 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned level,
|
||||
static int list_dependencies(sd_bus *bus, const char *name) {
|
||||
_cleanup_strv_free_ char **units = NULL;
|
||||
char ts[FORMAT_TIMESPAN_MAX];
|
||||
struct unit_times *times;
|
||||
UnitTimes *times;
|
||||
int r;
|
||||
const char *id;
|
||||
_cleanup_free_ char *path = NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
struct boot_times *boot;
|
||||
BootTimes *boot;
|
||||
|
||||
assert(bus);
|
||||
|
||||
@ -1021,7 +1015,7 @@ static int list_dependencies(sd_bus *bus, const char *name) {
|
||||
|
||||
static int analyze_critical_chain(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
_cleanup_(unit_times_freep) struct unit_times *times = NULL;
|
||||
_cleanup_(unit_times_free_arrayp) UnitTimes *times = NULL;
|
||||
Hashmap *h;
|
||||
int n, r;
|
||||
|
||||
@ -1037,7 +1031,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) {
|
||||
if (!h)
|
||||
return log_oom();
|
||||
|
||||
for (struct unit_times *u = times; u->has_data; u++) {
|
||||
for (UnitTimes *u = times; u->has_data; u++) {
|
||||
r = hashmap_put(h, u->name, u);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add entry to hashmap: %m");
|
||||
@ -1062,7 +1056,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) {
|
||||
|
||||
static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||
_cleanup_(unit_times_freep) struct unit_times *times = NULL;
|
||||
_cleanup_(unit_times_free_arrayp) UnitTimes *times = NULL;
|
||||
_cleanup_(table_unrefp) Table *table = NULL;
|
||||
TableCell *cell;
|
||||
int n, r;
|
||||
@ -1103,7 +1097,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
for (struct unit_times *u = times; u->has_data; u++) {
|
||||
for (UnitTimes *u = times; u->has_data; u++) {
|
||||
if (u->time <= 0)
|
||||
continue;
|
||||
|
||||
@ -1716,7 +1710,7 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
|
||||
if (strv_isempty(strv_skip(argv, 1))) {
|
||||
_cleanup_set_free_ Set *kernel = NULL, *known = NULL;
|
||||
const char *sys;
|
||||
int i, k;
|
||||
int k;
|
||||
|
||||
NULSTR_FOREACH(sys, syscall_filter_sets[SYSCALL_FILTER_SET_KNOWN].value)
|
||||
if (set_put_strdup(&known, sys) < 0)
|
||||
@ -1724,7 +1718,7 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
|
||||
|
||||
k = load_kernel_syscalls(&kernel);
|
||||
|
||||
for (i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
|
||||
for (int i = 0; i < _SYSCALL_FILTER_SET_MAX; i++) {
|
||||
const SyscallFilterSet *set = syscall_filter_sets + i;
|
||||
if (!first)
|
||||
puts("");
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "util.h"
|
||||
|
||||
int have_effective_cap(int value) {
|
||||
_cleanup_cap_free_ cap_t cap;
|
||||
_cleanup_cap_free_ cap_t cap = NULL;
|
||||
cap_flag_value_t fv;
|
||||
|
||||
cap = cap_get_proc();
|
||||
|
@ -25,7 +25,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities);
|
||||
|
||||
int drop_capability(cap_value_t cv);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(cap_t, cap_free, NULL);
|
||||
#define _cleanup_cap_free_ _cleanup_(cap_freep)
|
||||
|
||||
static inline void cap_free_charpp(char **p) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(void*, dlclose, NULL);
|
||||
|
||||
int dlsym_many_and_warn(void *dl, int level, ...);
|
||||
|
||||
|
@ -41,8 +41,8 @@ static inline void fclosep(FILE **f) {
|
||||
safe_fclose(*f);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, pclose, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
|
||||
|
||||
#define _cleanup_close_ _cleanup_(closep)
|
||||
#define _cleanup_fclose_ _cleanup_(fclosep)
|
||||
|
@ -1146,7 +1146,7 @@ static EndOfLineMarker categorize_eol(char c, ReadLineFlags flags) {
|
||||
return EOL_NONE;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, funlockfile);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, funlockfile, NULL);
|
||||
|
||||
int read_line_full(FILE *f, size_t limit, ReadLineFlags flags, char **ret) {
|
||||
size_t n = 0, allocated = 0, count = 0;
|
||||
|
@ -14,7 +14,7 @@
|
||||
void initialize_libgcrypt(bool secmem);
|
||||
int string_hashsum(const char *s, size_t len, int md_algorithm, char **out);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(gcry_md_hd_t, gcry_md_close);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gcry_md_hd_t, gcry_md_close, NULL);
|
||||
#endif
|
||||
|
||||
static inline int string_hashsum_sha224(const char *s, size_t len, char **out) {
|
||||
|
@ -405,10 +405,20 @@ static inline int __coverity_check_and_return__(int condition) {
|
||||
func(p); \
|
||||
}
|
||||
|
||||
/* When func() returns the void value (NULL, -1, …) of the appropriate type */
|
||||
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
|
||||
static inline void func##p(type *p) { \
|
||||
if (*p) \
|
||||
*p = func(*p); \
|
||||
}
|
||||
|
||||
/* When func() doesn't return the appropriate type, set variable to empty afterwards */
|
||||
#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(type, func, empty) \
|
||||
static inline void func##p(type *p) { \
|
||||
if (*p != (empty)) { \
|
||||
func(*p); \
|
||||
*p = (empty); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _DEFINE_TRIVIAL_REF_FUNC(type, name, scope) \
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "time-util.h"
|
||||
|
||||
#if HAVE_SELINUX
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(context_t, context_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(context_t, context_free, NULL);
|
||||
#define _cleanup_context_free_ _cleanup_(context_freep)
|
||||
|
||||
static int mac_selinux_reload(int seqno);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#if HAVE_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, freecon, NULL);
|
||||
#define _cleanup_freecon_ _cleanup_(freeconp)
|
||||
#endif
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
* ...
|
||||
*/
|
||||
|
||||
struct strbuf *strbuf_new(void) {
|
||||
struct strbuf* strbuf_new(void) {
|
||||
struct strbuf *str;
|
||||
|
||||
str = new(struct strbuf, 1);
|
||||
@ -65,13 +65,13 @@ void strbuf_complete(struct strbuf *str) {
|
||||
}
|
||||
|
||||
/* clean up everything */
|
||||
void strbuf_cleanup(struct strbuf *str) {
|
||||
struct strbuf* strbuf_free(struct strbuf *str) {
|
||||
if (!str)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
strbuf_complete(str);
|
||||
free(str->buf);
|
||||
free(str);
|
||||
return mfree(str);
|
||||
}
|
||||
|
||||
static int strbuf_children_cmp(const struct strbuf_child_entry *n1,
|
||||
|
@ -32,8 +32,8 @@ struct strbuf_child_entry {
|
||||
struct strbuf_node *child;
|
||||
};
|
||||
|
||||
struct strbuf *strbuf_new(void);
|
||||
struct strbuf* strbuf_new(void);
|
||||
ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
|
||||
void strbuf_complete(struct strbuf *str);
|
||||
void strbuf_cleanup(struct strbuf *str);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup);
|
||||
struct strbuf* strbuf_free(struct strbuf *str);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_free);
|
||||
|
@ -780,24 +780,22 @@ static int member_compare_funcp(Member * const *a, Member * const *b) {
|
||||
return member_compare_func(*a, *b);
|
||||
}
|
||||
|
||||
static void member_free(Member *m) {
|
||||
static Member* member_free(Member *m) {
|
||||
if (!m)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(m->interface);
|
||||
free(m->name);
|
||||
free(m->signature);
|
||||
free(m->result);
|
||||
free(m->value);
|
||||
free(m);
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Member*, member_free);
|
||||
|
||||
static void member_set_free(Set *s) {
|
||||
set_free_with_destructor(s, member_free);
|
||||
static Set* member_set_free(Set *s) {
|
||||
return set_free_with_destructor(s, member_free);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free);
|
||||
|
||||
static int on_interface(const char *interface, uint64_t flags, void *userdata) {
|
||||
|
@ -16,17 +16,17 @@
|
||||
#include "strv.h"
|
||||
|
||||
#if HAVE_APPARMOR
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(aa_policy_cache *, aa_policy_cache_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(aa_features *, aa_features_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_policy_cache *, aa_policy_cache_unref, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_features *, aa_features_unref, NULL);
|
||||
#endif
|
||||
|
||||
int mac_apparmor_setup(void) {
|
||||
#if HAVE_APPARMOR
|
||||
int r;
|
||||
_cleanup_(aa_policy_cache_unrefp) aa_policy_cache *policy_cache = NULL;
|
||||
_cleanup_(aa_features_unrefp) aa_features *features = NULL;
|
||||
const char *current_file;
|
||||
_cleanup_free_ char *current_profile = NULL, *cache_dir_path = NULL;
|
||||
int r;
|
||||
|
||||
if (!mac_apparmor_use()) {
|
||||
log_debug("AppArmor either not supported by the kernel or disabled.");
|
||||
|
@ -48,13 +48,13 @@ struct expire_data {
|
||||
int ioctl_fd;
|
||||
};
|
||||
|
||||
static void expire_data_free(struct expire_data *data) {
|
||||
static struct expire_data* expire_data_free(struct expire_data *data) {
|
||||
if (!data)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
safe_close(data->dev_autofs_fd);
|
||||
safe_close(data->ioctl_fd);
|
||||
free(data);
|
||||
return mfree(data);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct expire_data*, expire_data_free);
|
||||
|
@ -137,11 +137,11 @@ int setup_namespace(
|
||||
|
||||
#define RUN_SYSTEMD_EMPTY "/run/systemd/empty"
|
||||
|
||||
static inline void namespace_cleanup_tmpdir(char *p) {
|
||||
static inline char* namespace_cleanup_tmpdir(char *p) {
|
||||
PROTECT_ERRNO;
|
||||
if (!streq_ptr(p, RUN_SYSTEMD_EMPTY))
|
||||
(void) rmdir(p);
|
||||
free(p);
|
||||
return mfree(p);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, namespace_cleanup_tmpdir);
|
||||
|
||||
|
@ -969,6 +969,8 @@ static void socket_close_fds(Socket *s) {
|
||||
if (s->remove_on_stop)
|
||||
STRV_FOREACH(i, s->symlinks)
|
||||
(void) unlink(*i);
|
||||
|
||||
/* Note that we don't return NULL here, since s has not been freed. */
|
||||
}
|
||||
|
||||
static void socket_apply_socket_options(Socket *s, SocketPort *p, int fd) {
|
||||
@ -1609,10 +1611,10 @@ static int socket_address_listen_in_cgroup(
|
||||
return fd;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Socket *, socket_close_fds);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(Socket *, socket_close_fds, NULL);
|
||||
|
||||
static int socket_open_fds(Socket *_s) {
|
||||
_cleanup_(socket_close_fdsp) Socket *s = _s;
|
||||
static int socket_open_fds(Socket *orig_s) {
|
||||
_cleanup_(socket_close_fdsp) Socket *s = orig_s;
|
||||
_cleanup_(mac_selinux_freep) char *label = NULL;
|
||||
bool know_label = false;
|
||||
SocketPort *p;
|
||||
|
@ -82,7 +82,7 @@ const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
|
||||
|
||||
static void maybe_warn_about_dependency(Unit *u, const char *other, UnitDependency dependency);
|
||||
|
||||
Unit *unit_new(Manager *m, size_t size) {
|
||||
Unit* unit_new(Manager *m, size_t size) {
|
||||
Unit *u;
|
||||
|
||||
assert(m);
|
||||
@ -607,11 +607,11 @@ static void unit_done(Unit *u) {
|
||||
cgroup_context_done(cc);
|
||||
}
|
||||
|
||||
void unit_free(Unit *u) {
|
||||
Unit* unit_free(Unit *u) {
|
||||
char *t;
|
||||
|
||||
if (!u)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
u->transient_file = safe_fclose(u->transient_file);
|
||||
|
||||
@ -741,7 +741,7 @@ void unit_free(Unit *u) {
|
||||
set_free_free(u->aliases);
|
||||
free(u->id);
|
||||
|
||||
free(u);
|
||||
return mfree(u);
|
||||
}
|
||||
|
||||
FreezerState unit_freezer_state(Unit *u) {
|
||||
|
@ -674,8 +674,8 @@ static inline Unit* UNIT_TRIGGER(Unit *u) {
|
||||
return hashmap_first_key(u->dependencies[UNIT_TRIGGERS]);
|
||||
}
|
||||
|
||||
Unit *unit_new(Manager *m, size_t size);
|
||||
void unit_free(Unit *u);
|
||||
Unit* unit_new(Manager *m, size_t size);
|
||||
Unit* unit_free(Unit *u);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Unit *, unit_free);
|
||||
|
||||
int unit_new_for_name(Manager *m, size_t size, const char *name, Unit **ret);
|
||||
|
@ -22,24 +22,23 @@
|
||||
#define DEFAULT_KEEP_FREE_UPPER (uint64_t) (4ULL*1024ULL*1024ULL*1024ULL) /* 4 GiB */
|
||||
#define DEFAULT_KEEP_FREE (uint64_t) (1024ULL*1024ULL) /* 1 MB */
|
||||
|
||||
struct vacuum_candidate {
|
||||
typedef struct VacuumCandidate {
|
||||
unsigned n_files;
|
||||
char *oldest_file;
|
||||
usec_t oldest_mtime;
|
||||
};
|
||||
} VacuumCandidate;
|
||||
|
||||
static void vacuum_candidate_free(struct vacuum_candidate *c) {
|
||||
static VacuumCandidate* vacuum_candidate_free(VacuumCandidate *c) {
|
||||
if (!c)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(c->oldest_file);
|
||||
free(c);
|
||||
return mfree(c);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(VacuumCandidate*, vacuum_candidate_free);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct vacuum_candidate*, vacuum_candidate_free);
|
||||
|
||||
static void vacuum_candidate_hashmap_free(Hashmap *h) {
|
||||
hashmap_free_with_destructor(h, vacuum_candidate_free);
|
||||
static Hashmap* vacuum_candidate_hashmap_free(Hashmap *h) {
|
||||
return hashmap_free_with_destructor(h, vacuum_candidate_free);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, vacuum_candidate_hashmap_free);
|
||||
@ -142,14 +141,14 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
|
||||
|
||||
for (;;) {
|
||||
_cleanup_(vacuum_candidate_hashmap_freep) Hashmap *h = NULL;
|
||||
struct vacuum_candidate *worst = NULL;
|
||||
VacuumCandidate *worst = NULL;
|
||||
struct dirent *de;
|
||||
uint64_t sum = 0;
|
||||
|
||||
rewinddir(d);
|
||||
|
||||
FOREACH_DIRENT(de, d, goto fail) {
|
||||
struct vacuum_candidate *c;
|
||||
VacuumCandidate *c;
|
||||
struct stat st;
|
||||
uid_t uid;
|
||||
usec_t t;
|
||||
@ -196,9 +195,9 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
|
||||
}
|
||||
|
||||
} else {
|
||||
_cleanup_(vacuum_candidate_freep) struct vacuum_candidate *n = NULL;
|
||||
_cleanup_(vacuum_candidate_freep) VacuumCandidate *n = NULL;
|
||||
|
||||
n = new0(struct vacuum_candidate, 1);
|
||||
n = new0(VacuumCandidate, 1);
|
||||
if (!n)
|
||||
return log_oom();
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ static int manager_load_key_pair(Manager *m) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY_CTX*, EVP_PKEY_CTX_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY_CTX*, EVP_PKEY_CTX_free, NULL);
|
||||
|
||||
static int manager_generate_key_pair(Manager *m) {
|
||||
_cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = NULL;
|
||||
@ -1454,7 +1454,7 @@ int manager_sign_user_record(Manager *m, UserRecord *u, UserRecord **ret, sd_bus
|
||||
}
|
||||
|
||||
DEFINE_PRIVATE_HASH_OPS_FULL(public_key_hash_ops, char, string_hash_func, string_compare_func, free, EVP_PKEY, EVP_PKEY_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY*, EVP_PKEY_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY*, EVP_PKEY_free, NULL);
|
||||
|
||||
static int manager_load_public_key_one(Manager *m, const char *path) {
|
||||
_cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey = NULL;
|
||||
|
@ -1592,10 +1592,10 @@ static int luks_format(
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_context*, fdisk_unref_context);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_partition*, fdisk_unref_partition);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_parttype*, fdisk_unref_parttype);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_table*, fdisk_unref_table);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
|
||||
|
||||
static int make_partition_table(
|
||||
int fd,
|
||||
|
@ -27,7 +27,7 @@ static int user_record_signable_json(UserRecord *ur, char **ret) {
|
||||
return json_variant_format(j, 0, ret);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_MD_CTX*, EVP_MD_CTX_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_MD_CTX*, EVP_MD_CTX_free, NULL);
|
||||
|
||||
int user_record_sign(UserRecord *ur, EVP_PKEY *private_key, UserRecord **ret) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *encoded = NULL, *v = NULL;
|
||||
|
@ -34,6 +34,6 @@ struct curl_slist *curl_slist_new(const char *first, ...) _sentinel_;
|
||||
int curl_header_strdup(const void *contents, size_t sz, const char *field, char **value);
|
||||
int curl_parse_http_time(const char *t, usec_t *ret);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(CURL*, curl_easy_cleanup);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(CURLM*, curl_multi_cleanup);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct curl_slist*, curl_slist_free_all);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURLM*, curl_multi_cleanup, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
|
||||
|
@ -210,8 +210,9 @@ static int fifo_process(Fifo *f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fifo_free(Fifo *f) {
|
||||
assert(f);
|
||||
static Fifo* fifo_free(Fifo *f) {
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
if (f->server) {
|
||||
assert(f->server->n_fifos > 0);
|
||||
@ -226,7 +227,7 @@ static void fifo_free(Fifo *f) {
|
||||
safe_close(f->fd);
|
||||
}
|
||||
|
||||
free(f);
|
||||
return mfree(f);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Fifo*, fifo_free);
|
||||
|
||||
|
@ -80,5 +80,5 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn
|
||||
*/
|
||||
int setup_gnutls_logger(char **categories);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Daemon*, MHD_stop_daemon);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Response*, MHD_destroy_response);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct MHD_Daemon*, MHD_stop_daemon, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct MHD_Response*, MHD_destroy_response, NULL);
|
||||
|
@ -166,8 +166,8 @@ typedef struct BootId {
|
||||
} BootId;
|
||||
|
||||
#if HAVE_PCRE2
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_match_data*, sym_pcre2_match_data_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_code*, sym_pcre2_code_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_match_data*, sym_pcre2_match_data_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_code*, sym_pcre2_code_free, NULL);
|
||||
|
||||
static int pattern_compile(const char *pattern, unsigned flags, pcre2_code **out) {
|
||||
int errorcode, r;
|
||||
|
@ -98,9 +98,9 @@ struct StdoutStream {
|
||||
char id_field[STRLEN("_STREAM_ID=") + SD_ID128_STRING_MAX];
|
||||
};
|
||||
|
||||
void stdout_stream_free(StdoutStream *s) {
|
||||
StdoutStream* stdout_stream_free(StdoutStream *s) {
|
||||
if (!s)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (s->server) {
|
||||
|
||||
@ -129,7 +129,7 @@ void stdout_stream_free(StdoutStream *s) {
|
||||
free(s->state_file);
|
||||
free(s->buffer);
|
||||
|
||||
free(s);
|
||||
return mfree(s);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(StdoutStream*, stdout_stream_free);
|
||||
|
@ -9,7 +9,7 @@ typedef struct StdoutStream StdoutStream;
|
||||
int server_open_stdout_socket(Server *s, const char *stdout_socket);
|
||||
int server_restore_streams(Server *s, FDSet *fds);
|
||||
|
||||
void stdout_stream_free(StdoutStream *s);
|
||||
StdoutStream* stdout_stream_free(StdoutStream *s);
|
||||
int stdout_stream_install(Server *s, int fd, StdoutStream **ret);
|
||||
void stdout_stream_destroy(StdoutStream *s);
|
||||
void stdout_stream_send_notify(StdoutStream *s);
|
||||
|
@ -649,12 +649,12 @@ static int parse_request(uint8_t code, uint8_t len, const void *option, void *us
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dhcp_request_free(DHCPRequest *req) {
|
||||
static DHCPRequest* dhcp_request_free(DHCPRequest *req) {
|
||||
if (!req)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(req->client_id.data);
|
||||
free(req);
|
||||
return mfree(req);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DHCPRequest*, dhcp_request_free);
|
||||
|
@ -939,7 +939,7 @@ static void source_disconnect(sd_event_source *s) {
|
||||
sd_event_unref(event);
|
||||
}
|
||||
|
||||
static void source_free(sd_event_source *s) {
|
||||
static sd_event_source* source_free(sd_event_source *s) {
|
||||
assert(s);
|
||||
|
||||
source_disconnect(s);
|
||||
@ -989,7 +989,7 @@ static void source_free(sd_event_source *s) {
|
||||
s->destroy_callback(s->userdata);
|
||||
|
||||
free(s->description);
|
||||
free(s);
|
||||
return mfree(s);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_event_source*, source_free);
|
||||
|
||||
|
@ -115,13 +115,13 @@ static void trie_node_cleanup(struct trie_node *node) {
|
||||
free(node);
|
||||
}
|
||||
|
||||
static void trie_free(struct trie *trie) {
|
||||
static struct trie* trie_free(struct trie *trie) {
|
||||
if (!trie)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
trie_node_cleanup(trie->root);
|
||||
strbuf_cleanup(trie->strings);
|
||||
free(trie);
|
||||
strbuf_free(trie->strings);
|
||||
return mfree(trie);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct trie*, trie_free);
|
||||
|
@ -444,7 +444,7 @@ error:
|
||||
int catalog_update(const char* database, const char* root, const char* const* dirs) {
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
char **f;
|
||||
_cleanup_(strbuf_cleanupp) struct strbuf *sb = NULL;
|
||||
_cleanup_(strbuf_freep) struct strbuf *sb = NULL;
|
||||
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
|
||||
_cleanup_free_ CatalogItem *items = NULL;
|
||||
ssize_t offset;
|
||||
|
@ -34,13 +34,13 @@
|
||||
#include "util.h"
|
||||
|
||||
#if HAVE_LZ4
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_compressionContext_t, LZ4F_freeCompressionContext);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_decompressionContext_t, LZ4F_freeDecompressionContext);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_compressionContext_t, LZ4F_freeCompressionContext, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_decompressionContext_t, LZ4F_freeDecompressionContext, NULL);
|
||||
#endif
|
||||
|
||||
#if HAVE_ZSTD
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(ZSTD_CCtx *, ZSTD_freeCCtx);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(ZSTD_DCtx *, ZSTD_freeDCtx);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_CCtx*, ZSTD_freeCCtx, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_DCtx*, ZSTD_freeDCtx, NULL);
|
||||
|
||||
static int zstd_ret_to_errno(size_t ret) {
|
||||
switch (ZSTD_getErrorCode(ret)) {
|
||||
|
@ -44,9 +44,9 @@ typedef struct BrightnessWriter {
|
||||
sd_event_source* child_event_source;
|
||||
} BrightnessWriter;
|
||||
|
||||
static void brightness_writer_free(BrightnessWriter *w) {
|
||||
static BrightnessWriter* brightness_writer_free(BrightnessWriter *w) {
|
||||
if (!w)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (w->manager && w->path)
|
||||
(void) hashmap_remove_value(w->manager->brightness_writers, w->path, w);
|
||||
@ -59,7 +59,7 @@ static void brightness_writer_free(BrightnessWriter *w) {
|
||||
|
||||
w->child_event_source = sd_event_source_unref(w->child_event_source);
|
||||
|
||||
free(w);
|
||||
return mfree(w);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(BrightnessWriter*, brightness_writer_free);
|
||||
|
@ -39,18 +39,16 @@ static const char* const l2tp_local_address_type_table[_NETDEV_L2TP_LOCAL_ADDRES
|
||||
|
||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(l2tp_local_address_type, L2tpLocalAddressType);
|
||||
|
||||
static void l2tp_session_free(L2tpSession *s) {
|
||||
static L2tpSession* l2tp_session_free(L2tpSession *s) {
|
||||
if (!s)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (s->tunnel && s->section)
|
||||
ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
|
||||
|
||||
network_config_section_free(s->section);
|
||||
|
||||
free(s->name);
|
||||
|
||||
free(s);
|
||||
return mfree(s);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(L2tpSession, l2tp_session_free);
|
||||
|
@ -35,9 +35,9 @@ static void security_association_init(SecurityAssociation *sa) {
|
||||
sa->use_for_encoding = -1;
|
||||
}
|
||||
|
||||
static void macsec_receive_association_free(ReceiveAssociation *c) {
|
||||
static ReceiveAssociation* macsec_receive_association_free(ReceiveAssociation *c) {
|
||||
if (!c)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (c->macsec && c->section)
|
||||
ordered_hashmap_remove(c->macsec->receive_associations_by_section, c->section);
|
||||
@ -45,7 +45,7 @@ static void macsec_receive_association_free(ReceiveAssociation *c) {
|
||||
network_config_section_free(c->section);
|
||||
security_association_clear(&c->sa);
|
||||
|
||||
free(c);
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
|
||||
@ -90,9 +90,9 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void macsec_receive_channel_free(ReceiveChannel *c) {
|
||||
static ReceiveChannel* macsec_receive_channel_free(ReceiveChannel *c) {
|
||||
if (!c)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (c->macsec) {
|
||||
if (c->sci.as_uint64 > 0)
|
||||
@ -104,7 +104,7 @@ static void macsec_receive_channel_free(ReceiveChannel *c) {
|
||||
|
||||
network_config_section_free(c->section);
|
||||
|
||||
free(c);
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
|
||||
@ -162,9 +162,9 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void macsec_transmit_association_free(TransmitAssociation *a) {
|
||||
static TransmitAssociation* macsec_transmit_association_free(TransmitAssociation *a) {
|
||||
if (!a)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (a->macsec && a->section)
|
||||
ordered_hashmap_remove(a->macsec->transmit_associations_by_section, a->section);
|
||||
@ -172,7 +172,7 @@ static void macsec_transmit_association_free(TransmitAssociation *a) {
|
||||
network_config_section_free(a->section);
|
||||
security_association_clear(&a->sa);
|
||||
|
||||
free(a);
|
||||
return mfree(a);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
|
||||
|
@ -26,11 +26,11 @@
|
||||
|
||||
static void resolve_endpoints(NetDev *netdev);
|
||||
|
||||
static void wireguard_peer_free(WireguardPeer *peer) {
|
||||
static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
|
||||
WireguardIPmask *mask;
|
||||
|
||||
if (!peer)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (peer->wireguard) {
|
||||
LIST_REMOVE(peers, peer->wireguard->peers, peer);
|
||||
@ -54,7 +54,7 @@ static void wireguard_peer_free(WireguardPeer *peer) {
|
||||
free(peer->preshared_key_file);
|
||||
explicit_bzero_safe(peer->preshared_key, WG_KEY_LEN);
|
||||
|
||||
free(peer);
|
||||
return mfree(peer);
|
||||
}
|
||||
|
||||
DEFINE_NETWORK_SECTION_FUNCTIONS(WireguardPeer, wireguard_peer_free);
|
||||
|
@ -230,7 +230,7 @@ static int link_info_compare(const LinkInfo *a, const LinkInfo *b) {
|
||||
return CMP(a->ifindex, b->ifindex);
|
||||
}
|
||||
|
||||
static const LinkInfo* link_info_array_free(LinkInfo *array) {
|
||||
static LinkInfo* link_info_array_free(LinkInfo *array) {
|
||||
for (unsigned i = 0; array && array[i].needs_freeing; i++) {
|
||||
sd_device_unref(array[i].sd_device);
|
||||
free(array[i].ssid);
|
||||
|
@ -850,11 +850,11 @@ int manager_new(Manager **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void manager_free(Manager *m) {
|
||||
Manager* manager_free(Manager *m) {
|
||||
Link *link;
|
||||
|
||||
if (!m)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(m->state_file);
|
||||
|
||||
@ -909,7 +909,7 @@ void manager_free(Manager *m) {
|
||||
|
||||
m->fw_ctx = fw_ctx_free(m->fw_ctx);
|
||||
|
||||
free(m);
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
int manager_start(Manager *m) {
|
||||
|
@ -83,7 +83,7 @@ struct Manager {
|
||||
};
|
||||
|
||||
int manager_new(Manager **ret);
|
||||
void manager_free(Manager *m);
|
||||
Manager* manager_free(Manager *m);
|
||||
|
||||
int manager_connect_bus(Manager *m);
|
||||
int manager_start(Manager *m);
|
||||
|
@ -63,7 +63,6 @@ struct IPv6Token {
|
||||
};
|
||||
|
||||
int ipv6token_new(IPv6Token **ret);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(IPv6Token *, freep);
|
||||
|
||||
static inline char* NDISC_DNSSL_DOMAIN(const NDiscDNSSL *n) {
|
||||
return ((char*) n) + ALIGN(sizeof(NDiscDNSSL));
|
||||
|
@ -155,10 +155,6 @@ int network_config_section_new(const char *filename, unsigned line, NetworkConfi
|
||||
return 0;
|
||||
}
|
||||
|
||||
void network_config_section_free(NetworkConfigSection *cs) {
|
||||
free(cs);
|
||||
}
|
||||
|
||||
unsigned hashmap_find_free_section_line(Hashmap *hashmap) {
|
||||
NetworkConfigSection *cs;
|
||||
unsigned n = 0;
|
||||
|
@ -47,9 +47,12 @@ sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pur
|
||||
|
||||
int kernel_route_expiration_supported(void);
|
||||
|
||||
int network_config_section_new(const char *filename, unsigned line, NetworkConfigSection **s);
|
||||
void network_config_section_free(NetworkConfigSection *network);
|
||||
static inline NetworkConfigSection* network_config_section_free(NetworkConfigSection *cs) {
|
||||
return mfree(cs);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free);
|
||||
|
||||
int network_config_section_new(const char *filename, unsigned line, NetworkConfigSection **s);
|
||||
extern const struct hash_ops network_config_hash_ops;
|
||||
unsigned hashmap_find_free_section_line(Hashmap *hashmap);
|
||||
|
||||
@ -63,13 +66,14 @@ static inline bool section_is_invalid(NetworkConfigSection *section) {
|
||||
}
|
||||
|
||||
#define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \
|
||||
static inline void free_func##_or_set_invalid(type *p) { \
|
||||
static inline type* free_func##_or_set_invalid(type *p) { \
|
||||
assert(p); \
|
||||
\
|
||||
if (p->section) \
|
||||
p->section->invalid = true; \
|
||||
else \
|
||||
free_func(p); \
|
||||
return NULL; \
|
||||
} \
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);
|
||||
|
@ -134,9 +134,9 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qdisc_free(QDisc *qdisc) {
|
||||
QDisc* qdisc_free(QDisc *qdisc) {
|
||||
if (!qdisc)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (qdisc->network && qdisc->section)
|
||||
ordered_hashmap_remove(qdisc->network->tc_by_section, qdisc->section);
|
||||
@ -144,7 +144,7 @@ void qdisc_free(QDisc *qdisc) {
|
||||
network_config_section_free(qdisc->section);
|
||||
|
||||
free(qdisc->tca_kind);
|
||||
free(qdisc);
|
||||
return mfree(qdisc);
|
||||
}
|
||||
|
||||
static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
|
@ -74,7 +74,7 @@ extern const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX];
|
||||
/* For casting the various qdisc kinds into a qdisc */
|
||||
#define QDISC(q) (&(q)->meta)
|
||||
|
||||
void qdisc_free(QDisc *qdisc);
|
||||
QDisc* qdisc_free(QDisc *qdisc);
|
||||
int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret);
|
||||
|
||||
int qdisc_configure(Link *link, QDisc *qdisc);
|
||||
|
@ -90,16 +90,16 @@ int tclass_new_static(TClassKind kind, Network *network, const char *filename, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tclass_free(TClass *tclass) {
|
||||
TClass* tclass_free(TClass *tclass) {
|
||||
if (!tclass)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (tclass->network && tclass->section)
|
||||
ordered_hashmap_remove(tclass->network->tc_by_section, tclass->section);
|
||||
|
||||
network_config_section_free(tclass->section);
|
||||
|
||||
free(tclass);
|
||||
return mfree(tclass);
|
||||
}
|
||||
|
||||
static int tclass_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
|
@ -53,7 +53,7 @@ extern const TClassVTable * const tclass_vtable[_TCLASS_KIND_MAX];
|
||||
/* For casting the various tclass kinds into a tclass */
|
||||
#define TCLASS(t) (&(t)->meta)
|
||||
|
||||
void tclass_free(TClass *tclass);
|
||||
TClass* tclass_free(TClass *tclass);
|
||||
int tclass_new_static(TClassKind kind, Network *network, const char *filename, unsigned section_line, TClass **ret);
|
||||
|
||||
int tclass_configure(Link *link, TClass *tclass);
|
||||
|
@ -347,21 +347,18 @@ int manager_new(Manager **ret, Hashmap *interfaces, char **ignore,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void manager_free(Manager *m) {
|
||||
Manager* manager_free(Manager *m) {
|
||||
if (!m)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
hashmap_free_with_destructor(m->links, link_free);
|
||||
hashmap_free(m->links_by_name);
|
||||
|
||||
sd_event_source_unref(m->network_monitor_event_source);
|
||||
sd_network_monitor_unref(m->network_monitor);
|
||||
|
||||
sd_event_source_unref(m->rtnl_event_source);
|
||||
sd_netlink_unref(m->rtnl);
|
||||
|
||||
sd_event_unref(m->event);
|
||||
free(m);
|
||||
|
||||
return;
|
||||
return mfree(m);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ struct Manager {
|
||||
sd_event *event;
|
||||
};
|
||||
|
||||
void manager_free(Manager *m);
|
||||
Manager* manager_free(Manager *m);
|
||||
int manager_new(Manager **ret, Hashmap *interfaces, char **ignore,
|
||||
LinkOperationalStateRange required_operstate,
|
||||
bool any, usec_t timeout);
|
||||
|
@ -397,7 +397,7 @@ static int monitor_cgroup_contexts(Manager *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void manager_free(Manager *m) {
|
||||
Manager* manager_free(Manager *m) {
|
||||
assert(m);
|
||||
|
||||
varlink_close_unref(m->varlink);
|
||||
@ -410,7 +410,7 @@ void manager_free(Manager *m) {
|
||||
hashmap_free(m->monitored_swap_cgroup_contexts);
|
||||
hashmap_free(m->monitored_mem_pressure_cgroup_contexts);
|
||||
|
||||
free(m);
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
int manager_new(Manager **ret) {
|
||||
|
@ -51,7 +51,7 @@ struct Manager {
|
||||
Varlink *varlink;
|
||||
};
|
||||
|
||||
void manager_free(Manager *m);
|
||||
Manager* manager_free(Manager *m);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
||||
int manager_new(Manager **ret);
|
||||
|
@ -1268,10 +1268,10 @@ static int context_read_definitions(
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_context*, fdisk_unref_context);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_partition*, fdisk_unref_partition);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_parttype*, fdisk_unref_parttype);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_table*, fdisk_unref_table);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
|
||||
|
||||
static int determine_current_padding(
|
||||
struct fdisk_context *c,
|
||||
|
@ -82,17 +82,16 @@ static const char *dns_cache_item_type_to_string(DnsCacheItem *item) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dns_cache_item_free(DnsCacheItem *i) {
|
||||
static DnsCacheItem* dns_cache_item_free(DnsCacheItem *i) {
|
||||
if (!i)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
dns_resource_record_unref(i->rr);
|
||||
dns_resource_key_unref(i->key);
|
||||
dns_answer_unref(i->answer);
|
||||
dns_packet_unref(i->full_packet);
|
||||
free(i);
|
||||
return mfree(i);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsCacheItem*, dns_cache_item_free);
|
||||
|
||||
static void dns_cache_item_unlink_and_free(DnsCache *c, DnsCacheItem *i) {
|
||||
|
@ -162,23 +162,23 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsTransaction*, dns_transaction_free);
|
||||
|
||||
bool dns_transaction_gc(DnsTransaction *t) {
|
||||
DnsTransaction* dns_transaction_gc(DnsTransaction *t) {
|
||||
assert(t);
|
||||
|
||||
/* Returns !NULL if we can't gc yet. */
|
||||
|
||||
if (t->block_gc > 0)
|
||||
return true;
|
||||
return t;
|
||||
|
||||
if (set_isempty(t->notify_query_candidates) &&
|
||||
set_isempty(t->notify_query_candidates_done) &&
|
||||
set_isempty(t->notify_zone_items) &&
|
||||
set_isempty(t->notify_zone_items_done) &&
|
||||
set_isempty(t->notify_transactions) &&
|
||||
set_isempty(t->notify_transactions_done)) {
|
||||
dns_transaction_free(t);
|
||||
return false;
|
||||
}
|
||||
set_isempty(t->notify_transactions_done))
|
||||
return dns_transaction_free(t);
|
||||
|
||||
return true;
|
||||
return t;
|
||||
}
|
||||
|
||||
static uint16_t pick_new_id(Manager *m) {
|
||||
|
@ -140,7 +140,7 @@ struct DnsTransaction {
|
||||
int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key, DnsPacket *bypass, uint64_t flags);
|
||||
DnsTransaction* dns_transaction_free(DnsTransaction *t);
|
||||
|
||||
bool dns_transaction_gc(DnsTransaction *t);
|
||||
DnsTransaction* dns_transaction_gc(DnsTransaction *t);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsTransaction*, dns_transaction_gc);
|
||||
|
||||
int dns_transaction_go(DnsTransaction *t);
|
||||
|
@ -26,16 +26,15 @@ void dns_zone_item_probe_stop(DnsZoneItem *i) {
|
||||
dns_transaction_gc(t);
|
||||
}
|
||||
|
||||
static void dns_zone_item_free(DnsZoneItem *i) {
|
||||
static DnsZoneItem* dns_zone_item_free(DnsZoneItem *i) {
|
||||
if (!i)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
dns_zone_item_probe_stop(i);
|
||||
dns_resource_record_unref(i->rr);
|
||||
|
||||
free(i);
|
||||
return mfree(i);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsZoneItem*, dns_zone_item_free);
|
||||
|
||||
static void dns_zone_item_remove_and_free(DnsZone *z, DnsZoneItem *i) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "resolved-manager.h"
|
||||
|
||||
#define TLS_PROTOCOL_PRIORITY "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2"
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(gnutls_session_t, gnutls_deinit);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gnutls_session_t, gnutls_deinit, NULL);
|
||||
|
||||
static ssize_t dnstls_stream_writev(gnutls_transport_ptr_t p, const giovec_t *iov, int iovcnt) {
|
||||
int r;
|
||||
|
@ -21,13 +21,13 @@ int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask);
|
||||
|
||||
/* acl_free takes multiple argument types.
|
||||
* Multiple cleanup functions are necessary. */
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(acl_t, acl_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(acl_t, acl_free, NULL);
|
||||
#define acl_free_charp acl_free
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char*, acl_free_charp);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, acl_free_charp, NULL);
|
||||
#define acl_free_uid_tp acl_free
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(uid_t*, acl_free_uid_tp);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(uid_t*, acl_free_uid_tp, NULL);
|
||||
#define acl_free_gid_tp acl_free
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(gid_t*, acl_free_gid_tp);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gid_t*, acl_free_gid_tp, NULL);
|
||||
|
||||
#else
|
||||
#define ACL_READ 0x04
|
||||
|
@ -123,14 +123,15 @@ int barrier_create(Barrier *b) {
|
||||
*
|
||||
* If @b is NULL, this is a no-op.
|
||||
*/
|
||||
void barrier_destroy(Barrier *b) {
|
||||
Barrier* barrier_destroy(Barrier *b) {
|
||||
if (!b)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
b->me = safe_close(b->me);
|
||||
b->them = safe_close(b->them);
|
||||
safe_close_pair(b->pipe);
|
||||
b->barriers = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ struct Barrier {
|
||||
#define BARRIER_NULL {-1, -1, {-1, -1}, 0}
|
||||
|
||||
int barrier_create(Barrier *obj);
|
||||
void barrier_destroy(Barrier *b);
|
||||
Barrier* barrier_destroy(Barrier *b);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Barrier*, barrier_destroy);
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
||||
#define BITMAP_NUM_TO_REM(n) ((n) % (sizeof(uint64_t) * 8))
|
||||
#define BITMAP_OFFSET_TO_NUM(offset, rem) ((offset) * sizeof(uint64_t) * 8 + (rem))
|
||||
|
||||
Bitmap *bitmap_new(void) {
|
||||
Bitmap* bitmap_new(void) {
|
||||
return new0(Bitmap, 1);
|
||||
}
|
||||
|
||||
Bitmap *bitmap_copy(Bitmap *b) {
|
||||
Bitmap* bitmap_copy(Bitmap *b) {
|
||||
Bitmap *ret;
|
||||
|
||||
ret = bitmap_new();
|
||||
@ -43,12 +43,12 @@ Bitmap *bitmap_copy(Bitmap *b) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bitmap_free(Bitmap *b) {
|
||||
Bitmap* bitmap_free(Bitmap *b) {
|
||||
if (!b)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(b->bitmaps);
|
||||
free(b);
|
||||
return mfree(b);
|
||||
}
|
||||
|
||||
int bitmap_ensure_allocated(Bitmap **b) {
|
||||
|
@ -12,10 +12,10 @@ typedef struct Bitmap {
|
||||
size_t bitmaps_allocated;
|
||||
} Bitmap;
|
||||
|
||||
Bitmap *bitmap_new(void);
|
||||
Bitmap *bitmap_copy(Bitmap *b);
|
||||
Bitmap* bitmap_new(void);
|
||||
Bitmap* bitmap_copy(Bitmap *b);
|
||||
int bitmap_ensure_allocated(Bitmap **b);
|
||||
void bitmap_free(Bitmap *b);
|
||||
Bitmap* bitmap_free(Bitmap *b);
|
||||
|
||||
int bitmap_set(Bitmap *b, unsigned n);
|
||||
void bitmap_unset(Bitmap *b, unsigned n);
|
||||
|
@ -6,5 +6,5 @@
|
||||
|
||||
# include "macro.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(blkid_probe, blkid_free_probe);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(blkid_probe, blkid_free_probe, NULL);
|
||||
#endif
|
||||
|
@ -61,9 +61,9 @@ static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *er
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bus_wait_for_jobs_free(BusWaitForJobs *d) {
|
||||
BusWaitForJobs* bus_wait_for_jobs_free(BusWaitForJobs *d) {
|
||||
if (!d)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
set_free(d->jobs);
|
||||
|
||||
@ -75,7 +75,7 @@ void bus_wait_for_jobs_free(BusWaitForJobs *d) {
|
||||
free(d->name);
|
||||
free(d->result);
|
||||
|
||||
free(d);
|
||||
return mfree(d);
|
||||
}
|
||||
|
||||
int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret) {
|
||||
|
@ -8,7 +8,7 @@
|
||||
typedef struct BusWaitForJobs BusWaitForJobs;
|
||||
|
||||
int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret);
|
||||
void bus_wait_for_jobs_free(BusWaitForJobs *d);
|
||||
BusWaitForJobs* bus_wait_for_jobs_free(BusWaitForJobs *d);
|
||||
int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path);
|
||||
int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args);
|
||||
int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet);
|
||||
|
@ -33,14 +33,13 @@
|
||||
/* Let's make sure that the microsecond component is safe to be stored in an 'int' */
|
||||
assert_cc(INT_MAX >= USEC_PER_SEC);
|
||||
|
||||
static void chain_free(CalendarComponent *c) {
|
||||
CalendarComponent *n;
|
||||
|
||||
static CalendarComponent* chain_free(CalendarComponent *c) {
|
||||
while (c) {
|
||||
n = c->next;
|
||||
CalendarComponent *n = c->next;
|
||||
free(c);
|
||||
c = n;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarComponent*, chain_free);
|
||||
|
@ -50,8 +50,8 @@ static inline int sym_crypt_token_max(_unused_ const char *type) {
|
||||
|
||||
int dlopen_cryptsetup(void);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, crypt_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, sym_crypt_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, crypt_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, sym_crypt_free, NULL);
|
||||
|
||||
void cryptsetup_enable_logging(struct crypt_device *cd);
|
||||
|
||||
|
@ -1681,12 +1681,12 @@ static int verity_can_reuse(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void dm_deferred_remove_clean(char *name) {
|
||||
static inline char* dm_deferred_remove_clean(char *name) {
|
||||
if (!name)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
(void) sym_crypt_deactivate_by_name(NULL, name, CRYPT_DEACTIVATE_DEFERRED);
|
||||
free(name);
|
||||
return mfree(name);
|
||||
}
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char *, dm_deferred_remove_clean);
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "macro.h"
|
||||
#include "socket-util.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct xtc_handle*, iptc_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct xtc_handle*, iptc_free, NULL);
|
||||
|
||||
static int entry_fill_basics(
|
||||
struct ipt_entry *entry,
|
||||
|
@ -3346,12 +3346,12 @@ int unit_file_preset_all(
|
||||
return execute_preset(scope, &plus, &minus, &paths, config_path, NULL, mode, !!(flags & UNIT_FILE_FORCE), changes, n_changes);
|
||||
}
|
||||
|
||||
static void unit_file_list_free_one(UnitFileList *f) {
|
||||
static UnitFileList* unit_file_list_free_one(UnitFileList *f) {
|
||||
if (!f)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(f->path);
|
||||
free(f);
|
||||
return mfree(f);
|
||||
}
|
||||
|
||||
Hashmap* unit_file_list_free(Hashmap *h) {
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_table*, mnt_free_table, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_iter*, mnt_free_iter, NULL);
|
||||
|
||||
static inline int libmount_parse(
|
||||
const char *path,
|
||||
|
@ -7,6 +7,6 @@
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_ctx*, kmod_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_module*, kmod_module_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_list*, kmod_module_unref_list);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct kmod_list*, kmod_module_unref_list, NULL);
|
||||
|
||||
int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose);
|
||||
|
@ -45,7 +45,7 @@ int bind_remount_one_with_mountinfo(const char *path, unsigned long new_flags, u
|
||||
|
||||
int mount_move_root(const char *path);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, endmntent, NULL);
|
||||
#define _cleanup_endmntent_ _cleanup_(endmntentp)
|
||||
|
||||
int mount_verbose_full(
|
||||
|
@ -6,10 +6,10 @@
|
||||
#if HAVE_OPENSSL
|
||||
# include <openssl/pem.h>
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(X509*, X509_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(X509_NAME*, X509_NAME_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY_CTX*, EVP_PKEY_CTX_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_CIPHER_CTX*, EVP_CIPHER_CTX_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(X509*, X509_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(X509_NAME*, X509_NAME_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY_CTX*, EVP_PKEY_CTX_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_CIPHER_CTX*, EVP_CIPHER_CTX_free, NULL);
|
||||
|
||||
int rsa_encrypt_bytes(EVP_PKEY *pkey, const void *decrypted_key, size_t decrypted_key_size, void **ret_encrypt_key, size_t *ret_encrypt_key_size);
|
||||
|
||||
|
@ -21,8 +21,8 @@ P11KitUri *uri_from_module_info(const CK_INFO *info);
|
||||
P11KitUri *uri_from_slot_info(const CK_SLOT_INFO *slot_info);
|
||||
P11KitUri *uri_from_token_info(const CK_TOKEN_INFO *token_info);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(P11KitUri*, p11_kit_uri_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(CK_FUNCTION_LIST**, p11_kit_modules_finalize_and_release);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(P11KitUri*, p11_kit_uri_free, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CK_FUNCTION_LIST**, p11_kit_modules_finalize_and_release, NULL);
|
||||
|
||||
CK_RV pkcs11_get_slot_list_malloc(CK_FUNCTION_LIST *m, CK_SLOT_ID **ret_slotids, CK_ULONG *ret_n_slotids);
|
||||
|
||||
|
@ -19,7 +19,7 @@ extern const char* (*sym_pwquality_strerror)(char *buf, size_t len, int errcode,
|
||||
|
||||
int dlopen_pwquality(void);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(pwquality_settings_t*, sym_pwquality_free_settings);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_settings, NULL);
|
||||
|
||||
void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq);
|
||||
int pwq_allocate_context(pwquality_settings_t **ret);
|
||||
|
@ -121,7 +121,7 @@ extern uint32_t seccomp_local_archs[];
|
||||
#define ERRNO_IS_SECCOMP_FATAL(r) \
|
||||
IN_SET(abs(r), EPERM, EACCES, ENOMEM, EFAULT)
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(scmp_filter_ctx, seccomp_release);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(scmp_filter_ctx, seccomp_release, NULL);
|
||||
|
||||
int parse_syscall_archs(char **l, Set **ret_archs);
|
||||
|
||||
|
@ -6,9 +6,12 @@
|
||||
#include "env-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fuzz.h"
|
||||
#include "selinux-util.h"
|
||||
#include "static-destruct.h"
|
||||
#include "stdio-util.h"
|
||||
#include "strv.h"
|
||||
#include "systemctl.h"
|
||||
#include "systemctl-util.h"
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
_cleanup_strv_free_ char **argv = NULL;
|
||||
@ -54,5 +57,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
assert_se(freopen(path, "w", stdout));
|
||||
}
|
||||
|
||||
release_busses(); /* We open the bus for communication with logind.
|
||||
* It needs to be closed to avoid apparent leaks. */
|
||||
|
||||
mac_selinux_finish();
|
||||
|
||||
/* Call static destructors to do global state cleanup. We do it here, and not in fuzz-main.c so that
|
||||
* any global state is destoyed between fuzzer runs. */
|
||||
static_destruct();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -132,9 +132,10 @@ int shutdown_parse_argv(int argc, char *argv[]) {
|
||||
wall = argv + optind + 1;
|
||||
|
||||
if (wall) {
|
||||
arg_wall = strv_copy(wall);
|
||||
if (!arg_wall)
|
||||
char **copy = strv_copy(wall);
|
||||
if (!copy)
|
||||
return log_oom();
|
||||
strv_free_and_replace(arg_wall, copy);
|
||||
}
|
||||
|
||||
optind = argc;
|
||||
|
@ -147,15 +147,14 @@ typedef struct UnitCondition {
|
||||
LIST_FIELDS(struct UnitCondition, conditions);
|
||||
} UnitCondition;
|
||||
|
||||
static void unit_condition_free(UnitCondition *c) {
|
||||
static UnitCondition* unit_condition_free(UnitCondition *c) {
|
||||
if (!c)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(c->name);
|
||||
free(c->param);
|
||||
free(c);
|
||||
return mfree(c);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitCondition*, unit_condition_free);
|
||||
|
||||
typedef struct UnitStatusInfo {
|
||||
|
@ -1159,8 +1159,8 @@ static int run(int argc, char *argv[]) {
|
||||
case ACTION_SUSPEND_THEN_HIBERNATE:
|
||||
case ACTION_EMERGENCY:
|
||||
case ACTION_DEFAULT:
|
||||
/* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
|
||||
* arg_action. Fall through. */
|
||||
/* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
|
||||
* arg_action. Fall through. */
|
||||
|
||||
case _ACTION_INVALID:
|
||||
default:
|
||||
|
@ -59,9 +59,9 @@ typedef struct SysvStub {
|
||||
bool loaded;
|
||||
} SysvStub;
|
||||
|
||||
static void free_sysvstub(SysvStub *s) {
|
||||
static SysvStub* free_sysvstub(SysvStub *s) {
|
||||
if (!s)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(s->name);
|
||||
free(s->path);
|
||||
@ -71,9 +71,8 @@ static void free_sysvstub(SysvStub *s) {
|
||||
strv_free(s->after);
|
||||
strv_free(s->wants);
|
||||
strv_free(s->wanted_by);
|
||||
free(s);
|
||||
return mfree(s);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(SysvStub*, free_sysvstub);
|
||||
|
||||
static void free_sysvstub_hashmapp(Hashmap **h) {
|
||||
|
@ -12,7 +12,7 @@ static ssize_t add_string(struct strbuf *sb, const char *s) {
|
||||
}
|
||||
|
||||
static void test_strbuf(void) {
|
||||
_cleanup_(strbuf_cleanupp) struct strbuf *sb;
|
||||
_cleanup_(strbuf_freep) struct strbuf *sb;
|
||||
_cleanup_strv_free_ char **l;
|
||||
ssize_t a, b, c, d, e, f, g, h;
|
||||
|
||||
|
@ -915,9 +915,9 @@ void manager_flush_server_names(Manager *m, ServerType t) {
|
||||
server_name_free(m->fallback_servers);
|
||||
}
|
||||
|
||||
void manager_free(Manager *m) {
|
||||
Manager* manager_free(Manager *m) {
|
||||
if (!m)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
manager_disconnect(m);
|
||||
manager_flush_server_names(m, SERVER_SYSTEM);
|
||||
@ -934,7 +934,7 @@ void manager_free(Manager *m) {
|
||||
|
||||
sd_bus_flush_close_unref(m->bus);
|
||||
|
||||
free(m);
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
static int manager_network_read_link_servers(Manager *m) {
|
||||
|
@ -103,7 +103,7 @@ struct Manager {
|
||||
};
|
||||
|
||||
int manager_new(Manager **ret);
|
||||
void manager_free(Manager *m);
|
||||
Manager* manager_free(Manager *m);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
||||
|
@ -45,9 +45,9 @@ struct link_config_ctx {
|
||||
usec_t network_dirs_ts_usec;
|
||||
};
|
||||
|
||||
static void link_config_free(link_config *link) {
|
||||
static link_config* link_config_free(link_config *link) {
|
||||
if (!link)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(link->filename);
|
||||
|
||||
@ -62,7 +62,7 @@ static void link_config_free(link_config *link) {
|
||||
free(link->alternative_names_policy);
|
||||
free(link->alias);
|
||||
|
||||
free(link);
|
||||
return mfree(link);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(link_config*, link_config_free);
|
||||
@ -77,19 +77,14 @@ static void link_configs_free(link_config_ctx *ctx) {
|
||||
link_config_free(link);
|
||||
}
|
||||
|
||||
void link_config_ctx_free(link_config_ctx *ctx) {
|
||||
link_config_ctx* link_config_ctx_free(link_config_ctx *ctx) {
|
||||
if (!ctx)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
safe_close(ctx->ethtool_fd);
|
||||
|
||||
sd_netlink_unref(ctx->rtnl);
|
||||
|
||||
link_configs_free(ctx);
|
||||
|
||||
free(ctx);
|
||||
|
||||
return;
|
||||
return mfree(ctx);
|
||||
}
|
||||
|
||||
int link_config_ctx_new(link_config_ctx **ret) {
|
||||
|
@ -69,7 +69,7 @@ struct link_config {
|
||||
};
|
||||
|
||||
int link_config_ctx_new(link_config_ctx **ret);
|
||||
void link_config_ctx_free(link_config_ctx *ctx);
|
||||
link_config_ctx* link_config_ctx_free(link_config_ctx *ctx);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free);
|
||||
|
||||
int link_load_one(link_config_ctx *ctx, const char *filename);
|
||||
|
@ -164,9 +164,10 @@ static void udev_ctrl_disconnect_and_listen_again(struct udev_ctrl *uctrl) {
|
||||
udev_ctrl_disconnect(uctrl);
|
||||
udev_ctrl_unref(uctrl);
|
||||
(void) sd_event_source_set_enabled(uctrl->event_source, SD_EVENT_ON);
|
||||
/* We don't return NULL here because uctrl is not freed */
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl *, udev_ctrl_disconnect_and_listen_again);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct udev_ctrl*, udev_ctrl_disconnect_and_listen_again, NULL);
|
||||
|
||||
static int udev_ctrl_connection_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_(udev_ctrl_disconnect_and_listen_againp) struct udev_ctrl *uctrl = NULL;
|
||||
|
@ -264,9 +264,9 @@ static void udev_rule_line_clear_tokens(UdevRuleLine *rule_line) {
|
||||
rule_line->tokens = NULL;
|
||||
}
|
||||
|
||||
static void udev_rule_line_free(UdevRuleLine *rule_line) {
|
||||
static UdevRuleLine* udev_rule_line_free(UdevRuleLine *rule_line) {
|
||||
if (!rule_line)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
udev_rule_line_clear_tokens(rule_line);
|
||||
|
||||
@ -278,7 +278,7 @@ static void udev_rule_line_free(UdevRuleLine *rule_line) {
|
||||
}
|
||||
|
||||
free(rule_line->line);
|
||||
free(rule_line);
|
||||
return mfree(rule_line);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(UdevRuleLine*, udev_rule_line_free);
|
||||
|
@ -173,9 +173,9 @@ static void event_free(struct event *event) {
|
||||
free(event);
|
||||
}
|
||||
|
||||
static void worker_free(struct worker *worker) {
|
||||
static struct worker* worker_free(struct worker *worker) {
|
||||
if (!worker)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
assert(worker->manager);
|
||||
|
||||
@ -183,7 +183,7 @@ static void worker_free(struct worker *worker) {
|
||||
sd_device_monitor_unref(worker->monitor);
|
||||
event_free(worker->event);
|
||||
|
||||
free(worker);
|
||||
return mfree(worker);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct worker *, worker_free);
|
||||
@ -287,9 +287,9 @@ static void manager_clear_for_worker(Manager *manager) {
|
||||
manager->worker_watch[READ_END] = safe_close(manager->worker_watch[READ_END]);
|
||||
}
|
||||
|
||||
static void manager_free(Manager *manager) {
|
||||
static Manager* manager_free(Manager *manager) {
|
||||
if (!manager)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
udev_builtin_exit();
|
||||
|
||||
@ -306,7 +306,7 @@ static void manager_free(Manager *manager) {
|
||||
safe_close(manager->fd_inotify);
|
||||
safe_close_pair(manager->worker_watch);
|
||||
|
||||
free(manager);
|
||||
return mfree(manager);
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
||||
|
BIN
test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input
Normal file
BIN
test/fuzz/fuzz-systemctl-parse-argv/missing-strv-free.input
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user