1
0
mirror of https://github.com/systemd/systemd synced 2025-10-07 20:54:45 +02:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Yu Watanabe
22bbba8444 sd-dhcp-client: introduce sd_dhcp_client_is_running() 2021-04-14 22:31:28 +02:00
Luca Boccassi
9264fb47d9
Merge pull request #19315 from yuwata/network-wait-online-address-family-follow-ups
network: several follow-ups for #19069
2021-04-14 21:17:00 +01:00
Zbigniew Jędrzejewski-Szmek
c5cb37d95e
Merge pull request #19302 from bluca/uninit
tree-wide: avoid uninitialized warning on _cleanup_ variables
2021-04-14 16:25:35 +02:00
Yu Watanabe
f11bee0cb9 wait-online: update debug log messages 2021-04-14 22:17:44 +09:00
Yu Watanabe
90afec1834 network: shorten code a bit 2021-04-14 22:13:46 +09:00
Luca Boccassi
c2b2df604b tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.
2021-04-14 12:25:06 +01:00
Luca Boccassi
be084c0dd1 meson: build tests with -Wno-maybe-uninitialized if -O2/-flto are used
We intentionally do not inline initializations with definitions for
a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered.
This triggers a lot of maybe-uninitialized false positives when -O2 and
-flto are used. Suppress them.
2021-04-14 11:31:50 +01:00
Luca Boccassi
ab1aa6368a rfkill: add some casts to silence -Werror=sign-compare 2021-04-14 10:26:31 +01:00
68 changed files with 157 additions and 154 deletions

View File

@ -3318,6 +3318,11 @@ custom_target(
'} >@OUTPUT@'], '} >@OUTPUT@'],
build_by_default : true) build_by_default : true)
# We intentionally do not do inline initializations with definitions for
# a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered.
# This triggers a lot of maybe-uninitialized false positives when the
# combination of -O2 and -flto is used. Suppress them.
no_uninit = '-O2' in get_option('c_args') and '-flto=auto' in get_option('c_args') ? cc.first_supported_argument('-Wno-maybe-uninitialized') : []
foreach tuple : tests foreach tuple : tests
sources = tuple[0] sources = tuple[0]
link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared] link_with = tuple.length() > 1 and tuple[1].length() > 0 ? tuple[1] : [libshared]
@ -3326,6 +3331,7 @@ foreach tuple : tests
condition = tuple.length() > 4 ? tuple[4] : '' condition = tuple.length() > 4 ? tuple[4] : ''
type = tuple.length() > 5 ? tuple[5] : '' type = tuple.length() > 5 ? tuple[5] : ''
defs = tuple.length() > 6 ? tuple[6] : [] defs = tuple.length() > 6 ? tuple[6] : []
defs += no_uninit
parallel = tuple.length() > 7 ? tuple[7] : true parallel = tuple.length() > 7 ? tuple[7] : true
timeout = 30 timeout = 30
@ -3393,7 +3399,7 @@ exe = executable(
'test-libudev-sym', 'test-libudev-sym',
test_libudev_sym_c, test_libudev_sym_c,
include_directories : libudev_includes, include_directories : libudev_includes,
c_args : '-Wno-deprecated-declarations', c_args : ['-Wno-deprecated-declarations'] + no_uninit,
link_with : [libudev], link_with : [libudev],
build_by_default : want_tests != 'false', build_by_default : want_tests != 'false',
install : install_tests, install : install_tests,
@ -3406,7 +3412,7 @@ exe = executable(
'test-libudev-static-sym', 'test-libudev-static-sym',
test_libudev_sym_c, test_libudev_sym_c,
include_directories : libudev_includes, include_directories : libudev_includes,
c_args : '-Wno-deprecated-declarations', c_args : ['-Wno-deprecated-declarations'] + no_uninit,
link_with : [install_libudev_static], link_with : [install_libudev_static],
build_by_default : want_tests != 'false' and static_libudev_pic, build_by_default : want_tests != 'false' and static_libudev_pic,
install : install_tests and static_libudev_pic, install : install_tests and static_libudev_pic,

View File

@ -151,7 +151,7 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd,
envp[n_env++] = k; envp[n_env++] = k;
} else { } else {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
const char *n; const char *n;
p = strjoin(*s, "="); p = strjoin(*s, "=");
@ -421,7 +421,7 @@ static int parse_argv(int argc, char *argv[]) {
break; break;
case ARG_FDNAME: { case ARG_FDNAME: {
_cleanup_strv_free_ char **names; _cleanup_strv_free_ char **names = NULL;
char **s; char **s;
names = strv_split(optarg, ":"); names = strv_split(optarg, ":");
@ -430,7 +430,7 @@ static int parse_argv(int argc, char *argv[]) {
STRV_FOREACH(s, names) STRV_FOREACH(s, names)
if (!fdname_is_valid(*s)) { if (!fdname_is_valid(*s)) {
_cleanup_free_ char *esc; _cleanup_free_ char *esc = NULL;
esc = cescape(*s); esc = cescape(*s);
log_warning("File descriptor name \"%s\" is not valid.", esc); log_warning("File descriptor name \"%s\" is not valid.", esc);

View File

@ -350,7 +350,7 @@ int cache_efi_options_variable(void) {
* (NB: For testing purposes, we still check the $SYSTEMD_EFI_OPTIONS env var before accessing this * (NB: For testing purposes, we still check the $SYSTEMD_EFI_OPTIONS env var before accessing this
* cache, even when in SecureBoot mode.) */ * cache, even when in SecureBoot mode.) */
if (is_efi_secure_boot()) { if (is_efi_secure_boot()) {
_cleanup_free_ char *k; _cleanup_free_ char *k = NULL;
k = efi_variable_path(EFI_VENDOR_SYSTEMD, "SystemdOptions"); k = efi_variable_path(EFI_VENDOR_SYSTEMD, "SystemdOptions");
if (!k) if (!k)

View File

@ -772,7 +772,7 @@ void lookup_paths_log(LookupPaths *p) {
log_debug("Ignoring unit files."); log_debug("Ignoring unit files.");
p->search_path = strv_free(p->search_path); p->search_path = strv_free(p->search_path);
} else { } else {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strv_join(p->search_path, "\n\t"); t = strv_join(p->search_path, "\n\t");
log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t)); log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t));

View File

@ -52,7 +52,7 @@ static volatile int cached_color_mode = _COLOR_INVALID;
static volatile int cached_underline_enabled = -1; static volatile int cached_underline_enabled = -1;
int chvt(int vt) { int chvt(int vt) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
/* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go, /* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go,
* if that's configured. */ * if that's configured. */
@ -514,7 +514,7 @@ int terminal_vhangup_fd(int fd) {
} }
int terminal_vhangup(const char *name) { int terminal_vhangup(const char *name) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK); fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0) if (fd < 0)

View File

@ -1547,7 +1547,7 @@ int time_change_fd(void) {
.it_value.tv_sec = TIME_T_MAX, .it_value.tv_sec = TIME_T_MAX,
}; };
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX)); assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));

View File

@ -126,7 +126,7 @@ static int acquire_path(void) {
strv_free_and_replace(arg_path, a); strv_free_and_replace(arg_path, a);
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *j; _cleanup_free_ char *j = NULL;
j = strv_join(arg_path, ":"); j = strv_join(arg_path, ":");
log_debug("Using %s as boot loader drop-in search path.", j); log_debug("Using %s as boot loader drop-in search path.", j);

View File

@ -312,7 +312,7 @@ static int status_variables(void) {
} }
static int boot_entry_file_check(const char *root, const char *p) { static int boot_entry_file_check(const char *root, const char *p) {
_cleanup_free_ char *path; _cleanup_free_ char *path = NULL;
path = path_join(root, p); path = path_join(root, p);
if (!path) if (!path)

View File

@ -456,7 +456,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
device_path = DevicePathFromHandle(entry->device); device_path = DevicePathFromHandle(entry->device);
if (device_path) { if (device_path) {
_cleanup_freepool_ CHAR16 *str; _cleanup_freepool_ CHAR16 *str = NULL;
str = DevicePathToStr(device_path); str = DevicePathToStr(device_path);
Print(L"device handle '%s'\n", str); Print(L"device handle '%s'\n", str);

View File

@ -92,7 +92,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
* is non-NULL explicitly.) */ * is non-NULL explicitly.) */
if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS && if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS &&
loaded_image->FilePath) { loaded_image->FilePath) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = DevicePathToStr(loaded_image->FilePath); s = DevicePathToStr(loaded_image->FilePath);
efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0); efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
@ -100,7 +100,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* if LoaderFirmwareInfo is not set, let's set it */ /* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
@ -108,7 +108,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* ditto for LoaderFirmwareType */ /* ditto for LoaderFirmwareType */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) { if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s; _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0); efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);

View File

@ -379,7 +379,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
return err; return err;
if (size == 0) { if (size == 0) {
_cleanup_freepool_ EFI_FILE_INFO *info; _cleanup_freepool_ EFI_FILE_INFO *info = NULL;
info = LibFileInfo(handle); info = LibFileInfo(handle);
if (!info) if (!info)

View File

@ -797,7 +797,7 @@ static Set* member_set_free(Set *s) {
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free); DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free);
static int on_interface(const char *interface, uint64_t flags, void *userdata) { static int on_interface(const char *interface, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -828,7 +828,7 @@ static int on_interface(const char *interface, uint64_t flags, void *userdata) {
} }
static int on_method(const char *interface, const char *name, const char *signature, const char *result, uint64_t flags, void *userdata) { static int on_method(const char *interface, const char *name, const char *signature, const char *result, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -871,7 +871,7 @@ static int on_method(const char *interface, const char *name, const char *signat
} }
static int on_signal(const char *interface, const char *name, const char *signature, uint64_t flags, void *userdata) { static int on_signal(const char *interface, const char *name, const char *signature, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;
@ -910,7 +910,7 @@ static int on_signal(const char *interface, const char *name, const char *signat
} }
static int on_property(const char *interface, const char *name, const char *signature, bool writable, uint64_t flags, void *userdata) { static int on_property(const char *interface, const char *name, const char *signature, bool writable, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m; _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata; Set *members = userdata;
int r; int r;

View File

@ -1627,7 +1627,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHash="); unit_write_settingf(u, flags, name, "RootHash=");
} else { } else {
_cleanup_free_ void *p; _cleanup_free_ void *p = NULL;
encoded = hexmem(roothash_decoded, roothash_decoded_size); encoded = hexmem(roothash_decoded, roothash_decoded_size);
if (!encoded) if (!encoded)
@ -1673,7 +1673,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHashSignature="); unit_write_settingf(u, flags, name, "RootHashSignature=");
} else { } else {
_cleanup_free_ void *p; _cleanup_free_ void *p = NULL;
ssize_t len; ssize_t len;
len = base64mem(roothash_sig_decoded, roothash_sig_decoded_size, &encoded); len = base64mem(roothash_sig_decoded, roothash_sig_decoded_size, &encoded);

View File

@ -96,7 +96,7 @@ static int bus_path_set_transient_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in %s is not absolute: %s", type_name, path); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in %s is not absolute: %s", type_name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
_cleanup_free_ char *k; _cleanup_free_ char *k = NULL;
PathSpec *s; PathSpec *s;
k = strdup(path); k = strdup(path);

View File

@ -4639,7 +4639,7 @@ static int exec_child(
final_argv = command->argv; final_argv = command->argv;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *line; _cleanup_free_ char *line = NULL;
line = exec_command_line(final_argv); line = exec_command_line(final_argv);
if (line) if (line)
@ -4933,7 +4933,7 @@ int exec_context_destroy_runtime_directory(const ExecContext *c, const char *run
return 0; return 0;
STRV_FOREACH(i, c->directories[EXEC_DIRECTORY_RUNTIME].paths) { STRV_FOREACH(i, c->directories[EXEC_DIRECTORY_RUNTIME].paths) {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
if (exec_directory_is_private(c, EXEC_DIRECTORY_RUNTIME)) if (exec_directory_is_private(c, EXEC_DIRECTORY_RUNTIME))
p = path_join(runtime_prefix, "private", *i); p = path_join(runtime_prefix, "private", *i);

View File

@ -844,7 +844,7 @@ static void job_print_done_status_message(Unit *u, JobType t, JobResult result)
REENABLE_WARNING; REENABLE_WARNING;
if (t == JOB_START && result == JOB_FAILED) { if (t == JOB_START && result == JOB_FAILED) {
_cleanup_free_ char *quoted; _cleanup_free_ char *quoted = NULL;
quoted = shell_maybe_quote(u->id, ESCAPE_BACKSLASH); quoted = shell_maybe_quote(u->id, ESCAPE_BACKSLASH);
manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL, "See 'systemctl status %s' for details.", strna(quoted)); manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL, "See 'systemctl status %s' for details.", strna(quoted));

View File

@ -2036,7 +2036,7 @@ static void log_execution_mode(bool *ret_first_boot) {
} }
} else { } else {
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = uid_to_name(getuid()); t = uid_to_name(getuid());
log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (%s)", log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (%s)",

View File

@ -248,7 +248,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
} }
static int have_ask_password(void) { static int have_ask_password(void) {
_cleanup_closedir_ DIR *dir; _cleanup_closedir_ DIR *dir = NULL;
struct dirent *de; struct dirent *de;
dir = opendir("/run/systemd/ask-password"); dir = opendir("/run/systemd/ask-password");

View File

@ -2092,7 +2092,7 @@ int setup_namespace(
} }
if (log_namespace) { if (log_namespace) {
_cleanup_free_ char *q; _cleanup_free_ char *q = NULL;
q = strjoin("/run/systemd/journal.", log_namespace); q = strjoin("/run/systemd/journal.", log_namespace);
if (!q) { if (!q) {
@ -2331,7 +2331,7 @@ int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {
} }
LIST_FOREACH(mount_options, i, item->mount_options) { LIST_FOREACH(mount_options, i, item->mount_options) {
_cleanup_(mount_options_free_allp) MountOptions *o; _cleanup_(mount_options_free_allp) MountOptions *o = NULL;
o = new(MountOptions, 1); o = new(MountOptions, 1);
if (!o) if (!o)

View File

@ -4269,7 +4269,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock, bool selinux_context
if (getpeername_pretty(fd, true, &peer) >= 0) { if (getpeername_pretty(fd, true, &peer) >= 0) {
if (UNIT(s)->description) { if (UNIT(s)->description) {
_cleanup_free_ char *a; _cleanup_free_ char *a = NULL;
a = strjoin(UNIT(s)->description, " (", peer, ")"); a = strjoin(UNIT(s)->description, " (", peer, ")");
if (!a) if (!a)

View File

@ -557,7 +557,7 @@ static void unit_free_requires_mounts_for(Unit *u) {
assert(u); assert(u);
for (;;) { for (;;) {
_cleanup_free_ char *path; _cleanup_free_ char *path = NULL;
path = hashmap_steal_first_key(u->requires_mounts_for); path = hashmap_steal_first_key(u->requires_mounts_for);
if (!path) if (!path)
@ -1063,7 +1063,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
char **dp; char **dp;
STRV_FOREACH(dp, c->directories[dt].paths) { STRV_FOREACH(dp, c->directories[dt].paths) {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = path_join(u->manager->prefix[dt], *dp); p = path_join(u->manager->prefix[dt], *dp);
if (!p) if (!p)
@ -2184,7 +2184,7 @@ static int unit_log_resources(Unit *u) {
if (n_message_parts == 0) if (n_message_parts == 0)
t = strjoina("MESSAGE=", u->id, ": Completed."); t = strjoina("MESSAGE=", u->id, ": Completed.");
else { else {
_cleanup_free_ char *joined; _cleanup_free_ char *joined = NULL;
message_parts[n_message_parts] = NULL; message_parts[n_message_parts] = NULL;

View File

@ -588,7 +588,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) { static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) {
const char *p; const char *p;
struct stat stbuf; struct stat stbuf;
_cleanup_close_ int proc_ns_dir_fd; _cleanup_close_ int proc_ns_dir_fd = -1;
p = procfs_file_alloca(pid, "ns"); p = procfs_file_alloca(pid, "ns");

View File

@ -139,7 +139,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
return r; return r;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *filter; _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j); filter = journal_make_match_string(j);
log_debug("Journal filter: %s", filter); log_debug("Journal filter: %s", filter);
@ -979,7 +979,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
if (filename) { if (filename) {
#if HAVE_COMPRESSION #if HAVE_COMPRESSION
_cleanup_close_ int fdf; _cleanup_close_ int fdf = -1;
fdf = open(filename, O_RDONLY | O_CLOEXEC); fdf = open(filename, O_RDONLY | O_CLOEXEC);
if (fdf < 0) { if (fdf < 0) {

View File

@ -33,7 +33,7 @@ int find_key_file(
} }
STRV_FOREACH(i, search_path) { STRV_FOREACH(i, search_path) {
_cleanup_free_ char *joined; _cleanup_free_ char *joined = NULL;
joined = path_join(*i, key_file); joined = path_join(*i, key_file);
if (!joined) if (!joined)

View File

@ -29,7 +29,7 @@ static int environment_dirs(char ***ret) {
return r; return r;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strv_join(dirs, "\n\t"); t = strv_join(dirs, "\n\t");
log_debug("Looking for environment.d files in (higher priority first):\n\t%s", strna(t)); log_debug("Looking for environment.d files in (higher priority first):\n\t%s", strna(t));

View File

@ -460,7 +460,7 @@ static int add_mount(
return r; return r;
if (!isempty(fstype) && !streq(fstype, "auto")) { if (!isempty(fstype) && !streq(fstype, "auto")) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = specifier_escape(fstype); t = specifier_escape(fstype);
if (!t) if (!t)

View File

@ -311,7 +311,7 @@ static int request_parse_range(
colon2 = strchr(colon + 1, ':'); colon2 = strchr(colon + 1, ':');
if (colon2) { if (colon2) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strndup(colon + 1, colon2 - colon - 1); t = strndup(colon + 1, colon2 - colon - 1);
if (!t) if (!t)

View File

@ -40,7 +40,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
break; break;
case JOURNAL_WRITE_SPLIT_HOST: { case JOURNAL_WRITE_SPLIT_HOST: {
_cleanup_free_ char *name; _cleanup_free_ char *name = NULL;
assert(host); assert(host);

View File

@ -1158,7 +1158,7 @@ static int add_matches(sd_journal *j, char **args) {
if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) { if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
if (executable_is_script(p, &interpreter) > 0) { if (executable_is_script(p, &interpreter) > 0) {
_cleanup_free_ char *comm; _cleanup_free_ char *comm = NULL;
comm = strndup(basename(p), 15); comm = strndup(basename(p), 15);
if (!comm) if (!comm)
@ -1537,7 +1537,7 @@ static int get_possible_units(
char **patterns, char **patterns,
Set **units) { Set **units) {
_cleanup_set_free_free_ Set *found; _cleanup_set_free_free_ Set *found = NULL;
const char *field; const char *field;
int r; int r;
@ -2182,7 +2182,7 @@ int main(int argc, char *argv[]) {
case ACTION_LIST_CATALOG: case ACTION_LIST_CATALOG:
case ACTION_DUMP_CATALOG: case ACTION_DUMP_CATALOG:
case ACTION_UPDATE_CATALOG: { case ACTION_UPDATE_CATALOG: {
_cleanup_free_ char *database; _cleanup_free_ char *database = NULL;
database = path_join(arg_root, CATALOG_DATABASE); database = path_join(arg_root, CATALOG_DATABASE);
if (!database) { if (!database) {
@ -2436,7 +2436,7 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *filter; _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j); filter = journal_make_match_string(j);
if (!filter) if (!filter)

View File

@ -189,7 +189,7 @@ static int stdout_stream_save(StdoutStream *s) {
s->id_field + STRLEN("_STREAM_ID=")); s->id_field + STRLEN("_STREAM_ID="));
if (!isempty(s->identifier)) { if (!isempty(s->identifier)) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->identifier); escaped = cescape(s->identifier);
if (!escaped) { if (!escaped) {
@ -201,7 +201,7 @@ static int stdout_stream_save(StdoutStream *s) {
} }
if (!isempty(s->unit_id)) { if (!isempty(s->unit_id)) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->unit_id); escaped = cescape(s->unit_id);
if (!escaped) { if (!escaped) {

View File

@ -23,7 +23,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
} }
static void fuzz_client(const uint8_t *data, size_t size, bool is_information_request_enabled) { static void fuzz_client(const uint8_t *data, size_t size, bool is_information_request_enabled) {
_cleanup_(sd_event_unrefp) sd_event *e; _cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL; _cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } }; struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };

View File

@ -2052,6 +2052,13 @@ int sd_dhcp_client_send_renew(sd_dhcp_client *client) {
return client_initialize_time_events(client); return client_initialize_time_events(client);
} }
int sd_dhcp_client_is_running(const sd_dhcp_client *client) {
if (!client)
return 0;
return !IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_STOPPED);
}
int sd_dhcp_client_start(sd_dhcp_client *client) { int sd_dhcp_client_start(sd_dhcp_client *client) {
int r; int r;

View File

@ -88,7 +88,7 @@ static void patch_realtime(
} }
static int journal_file_empty(int dir_fd, const char *name) { static int journal_file_empty(int dir_fd, const char *name) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
struct stat st; struct stat st;
le64_t n_entries; le64_t n_entries;
ssize_t n; ssize_t n;

View File

@ -1860,7 +1860,7 @@ static int add_current_paths(sd_journal *j) {
* treat them as fatal. */ * treat them as fatal. */
ORDERED_HASHMAP_FOREACH(f, j->files) { ORDERED_HASHMAP_FOREACH(f, j->files) {
_cleanup_free_ char *dir; _cleanup_free_ char *dir = NULL;
int r; int r;
dir = dirname_malloc(f->path); dir = dirname_malloc(f->path);

View File

@ -775,7 +775,7 @@ _public_ int sd_get_sessions(char ***sessions) {
} }
_public_ int sd_get_uids(uid_t **users) { _public_ int sd_get_uids(uid_t **users) {
_cleanup_closedir_ DIR *d; _cleanup_closedir_ DIR *d = NULL;
struct dirent *de; struct dirent *de;
int r = 0; int r = 0;
unsigned n = 0; unsigned n = 0;

View File

@ -535,7 +535,7 @@ int vconsole_convert_to_x11(Context *c) {
int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) { int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) {
const char *dir; const char *dir;
_cleanup_free_ char *n; _cleanup_free_ char *n = NULL;
if (x11_variant) if (x11_variant)
n = strjoin(x11_layout, "-", x11_variant); n = strjoin(x11_layout, "-", x11_variant);

View File

@ -457,7 +457,7 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
(void) locale_update_system_manager(c, sd_bus_message_get_bus(m)); (void) locale_update_system_manager(c, sd_bus_message_get_bus(m));
if (settings) { if (settings) {
_cleanup_free_ char *line; _cleanup_free_ char *line = NULL;
line = strv_join(settings, ", "); line = strv_join(settings, ", ");
log_info("Changed locale to %s.", strnull(line)); log_info("Changed locale to %s.", strnull(line));

View File

@ -485,7 +485,7 @@ int config_parse_n_autovts(
static int vt_is_busy(unsigned vtnr) { static int vt_is_busy(unsigned vtnr) {
struct vt_stat vt_stat; struct vt_stat vt_stat;
int r; int r;
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
assert(vtnr >= 1); assert(vtnr >= 1);

View File

@ -1371,7 +1371,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
} }
static int flush_devices(Manager *m) { static int flush_devices(Manager *m) {
_cleanup_closedir_ DIR *d; _cleanup_closedir_ DIR *d = NULL;
assert(m); assert(m);
@ -2073,7 +2073,7 @@ static int update_schedule_file(Manager *m) {
m->scheduled_shutdown_type); m->scheduled_shutdown_type);
if (!isempty(m->wall_message)) { if (!isempty(m->wall_message)) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = cescape(m->wall_message); t = cescape(m->wall_message);
if (!t) { if (!t) {

View File

@ -266,7 +266,7 @@ int session_save(Session *s) {
fprintf(f, "DISPLAY=%s\n", s->display); fprintf(f, "DISPLAY=%s\n", s->display);
if (s->remote_host) { if (s->remote_host) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_host); escaped = cescape(s->remote_host);
if (!escaped) { if (!escaped) {
@ -278,7 +278,7 @@ int session_save(Session *s) {
} }
if (s->remote_user) { if (s->remote_user) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_user); escaped = cescape(s->remote_user);
if (!escaped) { if (!escaped) {
@ -290,7 +290,7 @@ int session_save(Session *s) {
} }
if (s->service) { if (s->service) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->service); escaped = cescape(s->service);
if (!escaped) { if (!escaped) {
@ -302,7 +302,7 @@ int session_save(Session *s) {
} }
if (s->desktop) { if (s->desktop) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->desktop); escaped = cescape(s->desktop);
if (!escaped) { if (!escaped) {

View File

@ -134,7 +134,7 @@ int machine_save(Machine *m) {
m->name); m->name);
if (m->unit) { if (m->unit) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->unit); escaped = cescape(m->unit);
if (!escaped) { if (!escaped) {
@ -149,7 +149,7 @@ int machine_save(Machine *m) {
fprintf(f, "SCOPE_JOB=%s\n", m->scope_job); fprintf(f, "SCOPE_JOB=%s\n", m->scope_job);
if (m->service) { if (m->service) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->service); escaped = cescape(m->service);
if (!escaped) { if (!escaped) {
@ -160,7 +160,7 @@ int machine_save(Machine *m) {
} }
if (m->root_directory) { if (m->root_directory) {
_cleanup_free_ char *escaped; _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->root_directory); escaped = cescape(m->root_directory);
if (!escaped) { if (!escaped) {

View File

@ -46,7 +46,7 @@ static int netdev_fill_tuntap_message(NetDev *netdev, struct ifreq *ifr) {
} }
static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
_cleanup_close_ int fd; _cleanup_close_ int fd = -1;
TunTap *t = NULL; TunTap *t = NULL;
const char *user; const char *user;
const char *group; const char *group;

View File

@ -182,7 +182,7 @@ void link_update_operstate(Link *link, bool also_update_master) {
LinkCarrierState carrier_state; LinkCarrierState carrier_state;
LinkAddressState ipv4_address_state, ipv6_address_state, address_state; LinkAddressState ipv4_address_state, ipv6_address_state, address_state;
_cleanup_strv_free_ char **p = NULL; _cleanup_strv_free_ char **p = NULL;
uint8_t ipv4_scope = RT_SCOPE_NOWHERE, ipv6_scope = RT_SCOPE_NOWHERE, scope; uint8_t ipv4_scope = RT_SCOPE_NOWHERE, ipv6_scope = RT_SCOPE_NOWHERE;
bool changed = false; bool changed = false;
Address *address; Address *address;
@ -215,11 +215,11 @@ void link_update_operstate(Link *link, bool also_update_master) {
if (!address_is_ready(address)) if (!address_is_ready(address))
continue; continue;
if (address->family == AF_INET && address->scope < ipv4_scope) if (address->family == AF_INET)
ipv4_scope = address->scope; ipv4_scope = MIN(ipv4_scope, address->scope);
if (address->family == AF_INET6 && address->scope < ipv6_scope) if (address->family == AF_INET6)
ipv6_scope = address->scope; ipv6_scope = MIN(ipv6_scope, address->scope);
} }
/* for operstate we also take foreign addresses into account */ /* for operstate we also take foreign addresses into account */
@ -227,18 +227,16 @@ void link_update_operstate(Link *link, bool also_update_master) {
if (!address_is_ready(address)) if (!address_is_ready(address))
continue; continue;
if (address->family == AF_INET && address->scope < ipv4_scope) if (address->family == AF_INET)
ipv4_scope = address->scope; ipv4_scope = MIN(ipv4_scope, address->scope);
if (address->family == AF_INET6 && address->scope < ipv6_scope) if (address->family == AF_INET6)
ipv6_scope = address->scope; ipv6_scope = MIN(ipv6_scope, address->scope);
} }
ipv4_address_state = address_state_from_scope(ipv4_scope); ipv4_address_state = address_state_from_scope(ipv4_scope);
ipv6_address_state = address_state_from_scope(ipv6_scope); ipv6_address_state = address_state_from_scope(ipv6_scope);
address_state = address_state_from_scope(MIN(ipv4_scope, ipv6_scope));
scope = MIN(ipv4_scope, ipv6_scope);
address_state = address_state_from_scope(scope);
/* Mapping of address and carrier state vs operational state /* Mapping of address and carrier state vs operational state
* carrier state * carrier state

View File

@ -125,20 +125,11 @@ int manager_save(Manager *m) {
if (link->flags & IFF_LOOPBACK) if (link->flags & IFF_LOOPBACK)
continue; continue;
if (link->operstate > operstate) operstate = MAX(operstate, link->operstate);
operstate = link->operstate; carrier_state = MAX(carrier_state, link->carrier_state);
address_state = MAX(address_state, link->address_state);
if (link->carrier_state > carrier_state) ipv4_address_state = MAX(ipv4_address_state, link->ipv4_address_state);
carrier_state = link->carrier_state; ipv6_address_state = MAX(ipv6_address_state, link->ipv6_address_state);
if (link->address_state > address_state)
address_state = link->address_state;
if (link->ipv4_address_state > ipv4_address_state)
ipv4_address_state = link->ipv4_address_state;
if (link->ipv6_address_state > ipv6_address_state)
ipv6_address_state = link->ipv6_address_state;
if (!link->network) if (!link->network)
continue; continue;

View File

@ -72,30 +72,30 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
needs_ipv6 = required_family & ADDRESS_FAMILY_IPV6; needs_ipv6 = required_family & ADDRESS_FAMILY_IPV6;
if (s.min >= LINK_OPERSTATE_DEGRADED) { if (s.min >= LINK_OPERSTATE_DEGRADED) {
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_DEGRADED) if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_DEGRADED) {
goto ipv4_not_ready; log_link_debug(l, "No routable or link-local IPv4 address is configured.");
return 0;
}
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_DEGRADED) if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_DEGRADED) {
goto ipv6_not_ready; log_link_debug(l, "No routable or link-local IPv6 address is configured.");
return 0;
}
} }
if (s.min >= LINK_OPERSTATE_ROUTABLE) { if (s.min >= LINK_OPERSTATE_ROUTABLE) {
if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_ROUTABLE) if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_ROUTABLE) {
goto ipv4_not_ready; log_link_debug(l, "No routable IPv4 address is configured.");
return 0;
}
if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_ROUTABLE) if (needs_ipv6 && l->ipv6_address_state < LINK_ADDRESS_STATE_ROUTABLE) {
goto ipv6_not_ready; log_link_debug(l, "No routable IPv6 address is configured.");
return 0;
}
} }
return 1; return 1;
ipv4_not_ready:
log_link_debug(l, "No routable or link-local IPv4 address is configured.");
return 0;
ipv6_not_ready:
log_link_debug(l, "No routable or link-local IPv6 address is configured.");
return 0;
} }
bool manager_configured(Manager *m) { bool manager_configured(Manager *m) {

View File

@ -56,7 +56,7 @@ static int help(void) {
static int parse_interface_with_operstate_range(const char *str) { static int parse_interface_with_operstate_range(const char *str) {
_cleanup_free_ char *ifname = NULL; _cleanup_free_ char *ifname = NULL;
_cleanup_free_ LinkOperationalStateRange *range; _cleanup_free_ LinkOperationalStateRange *range = NULL;
const char *p; const char *p;
int r; int r;

View File

@ -861,7 +861,7 @@ static int find_profile(const char *name, const char *unit, char **ret) {
assert_se(dot = strrchr(unit, '.')); assert_se(dot = strrchr(unit, '.'));
NULSTR_FOREACH(p, profile_dirs) { NULSTR_FOREACH(p, profile_dirs) {
_cleanup_free_ char *joined; _cleanup_free_ char *joined = NULL;
joined = strjoin(p, "/", name, "/", dot + 1, ".conf"); joined = strjoin(p, "/", name, "/", dot + 1, ".conf");
if (!joined) if (!joined)

View File

@ -341,7 +341,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
nl = true; nl = true;
} else { } else {
_cleanup_free_ char *pretty_portable = NULL, *pretty_os = NULL; _cleanup_free_ char *pretty_portable = NULL, *pretty_os = NULL;
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f = NULL;
f = fmemopen_unlocked((void*) data, sz, "re"); f = fmemopen_unlocked((void*) data, sz, "re");
if (!f) if (!f)

View File

@ -1447,7 +1447,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
/* Since all the active services are in the zone make them discoverable now. */ /* Since all the active services are in the zone make them discoverable now. */
SET_FOREACH(service_type, types) { SET_FOREACH(service_type, types) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr; _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR, rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR,
"_services._dns-sd._udp.local"); "_services._dns-sd._udp.local");

View File

@ -177,7 +177,7 @@ static int load_state(Context *c, const struct rfkill_event *event) {
ssize_t l = write(c->rfkill_fd, &we, sizeof we); ssize_t l = write(c->rfkill_fd, &we, sizeof we);
if (l < 0) if (l < 0)
return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx); return log_error_errno(errno, "Failed to restore rfkill state for %i: %m", event->idx);
if (l < RFKILL_EVENT_SIZE_V1) if ((size_t)l < RFKILL_EVENT_SIZE_V1) /* l cannot be < 0 here. Cast to fix -Werror=sign-compare */
return log_error_errno(SYNTHETIC_ERRNO(EIO), return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).", "Couldn't write rfkill event structure, too short (wrote %zd of %zu bytes).",
l, sizeof we); l, sizeof we);
@ -335,9 +335,9 @@ static int run(int argc, char *argv[]) {
break; break;
} }
if (l < RFKILL_EVENT_SIZE_V1) if ((size_t)l < RFKILL_EVENT_SIZE_V1) /* l cannot be < 0 here. Cast to fix -Werror=sign-compare */
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %d)", return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read of struct rfkill_event: (%zd < %zu)",
l, RFKILL_EVENT_SIZE_V1); l, (size_t) RFKILL_EVENT_SIZE_V1); /* Casting necessary to make compiling with different kernel versions happy */
log_debug("Reading struct rfkill_event: got %zd bytes.", l); log_debug("Reading struct rfkill_event: got %zd bytes.", l);
/* The event structure has more fields. We only care about the first few, so it's OK if we /* The event structure has more fields. We only care about the first few, so it's OK if we

View File

@ -211,7 +211,7 @@ int acl_search_groups(const char *path, char ***ret_groups) {
int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) { int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) {
_cleanup_free_ char **a = NULL, **d = NULL; /* strings are not freed */ _cleanup_free_ char **a = NULL, **d = NULL; /* strings are not freed */
_cleanup_strv_free_ char **split; _cleanup_strv_free_ char **split = NULL;
char **entry; char **entry;
int r = -EINVAL; int r = -EINVAL;
_cleanup_(acl_freep) acl_t a_acl = NULL, d_acl = NULL; _cleanup_(acl_freep) acl_t a_acl = NULL, d_acl = NULL;
@ -233,7 +233,7 @@ int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want
} }
if (!strv_isempty(a)) { if (!strv_isempty(a)) {
_cleanup_free_ char *join; _cleanup_free_ char *join = NULL;
join = strv_join(a, ","); join = strv_join(a, ",");
if (!join) if (!join)
@ -251,7 +251,7 @@ int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want
} }
if (!strv_isempty(d)) { if (!strv_isempty(d)) {
_cleanup_free_ char *join; _cleanup_free_ char *join = NULL;
join = strv_join(d, ","); join = strv_join(d, ",");
if (!join) if (!join)

View File

@ -184,7 +184,7 @@ static void log_job_error_with_service_result(const char* service, const char *r
service_shell_quoted = shell_maybe_quote(service, ESCAPE_BACKSLASH); service_shell_quoted = shell_maybe_quote(service, ESCAPE_BACKSLASH);
if (!strv_isempty((char**) extra_args)) { if (!strv_isempty((char**) extra_args)) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = strv_join((char**) extra_args, " "); t = strv_join((char**) extra_args, " ");
systemctl = strjoina("systemctl ", t ? : "<args>"); systemctl = strjoina("systemctl ", t ? : "<args>");

View File

@ -240,7 +240,7 @@ static int clean_posix_shm_internal(const char *dirname, DIR *dir, uid_t uid, gi
} }
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
_cleanup_closedir_ DIR *kid; _cleanup_closedir_ DIR *kid = NULL;
kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME); kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME);
if (!kid) { if (!kid) {

View File

@ -55,7 +55,7 @@ int clock_set_hwclock(const struct tm *tm) {
} }
int clock_is_localtime(const char* adjtime_path) { int clock_is_localtime(const char* adjtime_path) {
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f = NULL;
int r; int r;
if (!adjtime_path) if (!adjtime_path)

View File

@ -1409,7 +1409,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
case TABLE_TIMESTAMP: case TABLE_TIMESTAMP:
case TABLE_TIMESTAMP_UTC: case TABLE_TIMESTAMP_UTC:
case TABLE_TIMESTAMP_RELATIVE: { case TABLE_TIMESTAMP_RELATIVE: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
char *ret; char *ret;
p = new(char, FORMAT_TIMESTAMP_MAX); p = new(char, FORMAT_TIMESTAMP_MAX);
@ -1431,7 +1431,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
case TABLE_TIMESPAN: case TABLE_TIMESPAN:
case TABLE_TIMESPAN_MSEC: { case TABLE_TIMESPAN_MSEC: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, FORMAT_TIMESPAN_MAX); p = new(char, FORMAT_TIMESPAN_MAX);
if (!p) if (!p)
@ -1446,7 +1446,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_SIZE: { case TABLE_SIZE: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, FORMAT_BYTES_MAX); p = new(char, FORMAT_BYTES_MAX);
if (!p) if (!p)
@ -1460,7 +1460,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_BPS: { case TABLE_BPS: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
size_t n; size_t n;
p = new(char, FORMAT_BYTES_MAX+2); p = new(char, FORMAT_BYTES_MAX+2);
@ -1478,7 +1478,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_INT: { case TABLE_INT: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int_val) + 1); p = new(char, DECIMAL_STR_WIDTH(d->int_val) + 1);
if (!p) if (!p)
@ -1490,7 +1490,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_INT8: { case TABLE_INT8: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int8) + 1); p = new(char, DECIMAL_STR_WIDTH(d->int8) + 1);
if (!p) if (!p)
@ -1502,7 +1502,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_INT16: { case TABLE_INT16: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int16) + 1); p = new(char, DECIMAL_STR_WIDTH(d->int16) + 1);
if (!p) if (!p)
@ -1514,7 +1514,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_INT32: { case TABLE_INT32: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int32) + 1); p = new(char, DECIMAL_STR_WIDTH(d->int32) + 1);
if (!p) if (!p)
@ -1526,7 +1526,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_INT64: { case TABLE_INT64: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int64) + 1); p = new(char, DECIMAL_STR_WIDTH(d->int64) + 1);
if (!p) if (!p)
@ -1538,7 +1538,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_UINT: { case TABLE_UINT: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint_val) + 1); p = new(char, DECIMAL_STR_WIDTH(d->uint_val) + 1);
if (!p) if (!p)
@ -1550,7 +1550,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_UINT8: { case TABLE_UINT8: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint8) + 1); p = new(char, DECIMAL_STR_WIDTH(d->uint8) + 1);
if (!p) if (!p)
@ -1562,7 +1562,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_UINT16: { case TABLE_UINT16: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint16) + 1); p = new(char, DECIMAL_STR_WIDTH(d->uint16) + 1);
if (!p) if (!p)
@ -1574,7 +1574,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_UINT32: { case TABLE_UINT32: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint32) + 1); p = new(char, DECIMAL_STR_WIDTH(d->uint32) + 1);
if (!p) if (!p)
@ -1586,7 +1586,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_UINT64: { case TABLE_UINT64: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint64) + 1); p = new(char, DECIMAL_STR_WIDTH(d->uint64) + 1);
if (!p) if (!p)
@ -1598,7 +1598,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
} }
case TABLE_PERCENT: { case TABLE_PERCENT: {
_cleanup_free_ char *p; _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->percent) + 2); p = new(char, DECIMAL_STR_WIDTH(d->percent) + 2);
if (!p) if (!p)

View File

@ -2950,7 +2950,7 @@ static int read_presets(UnitFileScope scope, const char *root_dir, UnitFilePrese
return r; return r;
STRV_FOREACH(p, files) { STRV_FOREACH(p, files) {
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f = NULL;
int n = 0; int n = 0;
f = fopen(*p, "re"); f = fopen(*p, "re");

View File

@ -294,7 +294,7 @@ static bool print_multiline(
continuation * prefix, "", continuation * prefix, "",
color_on, len, pos, color_off); color_on, len, pos, color_off);
else { else {
_cleanup_free_ char *e; _cleanup_free_ char *e = NULL;
e = ellipsize_mem(pos, len, n_columns - prefix, e = ellipsize_mem(pos, len, n_columns - prefix,
tail_line ? 100 : 90); tail_line ? 100 : 90);
@ -1651,7 +1651,7 @@ int show_journal_by_unit(
return r; return r;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *filter; _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j); filter = journal_make_match_string(j);
if (!filter) if (!filter)

View File

@ -147,7 +147,7 @@ bool net_match_config(
const char *ssid, const char *ssid,
const struct ether_addr *bssid) { const struct ether_addr *bssid) {
_cleanup_free_ char *iftype_str; _cleanup_free_ char *iftype_str = NULL;
const char *path = NULL; const char *path = NULL;
assert(match); assert(match);

View File

@ -34,7 +34,7 @@
#include "time-util.h" #include "time-util.h"
int parse_sleep_config(SleepConfig **ret_sleep_config) { int parse_sleep_config(SleepConfig **ret_sleep_config) {
_cleanup_(free_sleep_configp) SleepConfig *sc; _cleanup_(free_sleep_configp) SleepConfig *sc = NULL;
int allow_suspend = -1, allow_hibernate = -1, int allow_suspend = -1, allow_hibernate = -1,
allow_s2h = -1, allow_hybrid_sleep = -1; allow_s2h = -1, allow_hybrid_sleep = -1;

View File

@ -576,7 +576,7 @@ end:
/* Removing empty dropin dirs */ /* Removing empty dropin dirs */
if (!arg_full) { if (!arg_full) {
_cleanup_free_ char *dir; _cleanup_free_ char *dir = NULL;
dir = dirname_malloc(*original); dir = dirname_malloc(*original);
if (!dir) if (!dir)

View File

@ -24,7 +24,7 @@ static int get_unit_list_recursive(
char ***ret_machines) { char ***ret_machines) {
_cleanup_free_ UnitInfo *unit_infos = NULL; _cleanup_free_ UnitInfo *unit_infos = NULL;
_cleanup_(message_set_freep) Set *replies; _cleanup_(message_set_freep) Set *replies = NULL;
sd_bus_message *reply; sd_bus_message *reply;
int c, r; int c, r;

View File

@ -1282,7 +1282,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
while ((r = exec_status_info_deserialize(m, &info, is_ex_prop)) > 0) { while ((r = exec_status_info_deserialize(m, &info, is_ex_prop)) > 0) {
char timestamp1[FORMAT_TIMESTAMP_MAX], timestamp2[FORMAT_TIMESTAMP_MAX]; char timestamp1[FORMAT_TIMESTAMP_MAX], timestamp2[FORMAT_TIMESTAMP_MAX];
_cleanup_strv_free_ char **optv = NULL; _cleanup_strv_free_ char **optv = NULL;
_cleanup_free_ char *tt, *o = NULL; _cleanup_free_ char *tt = NULL, *o = NULL;
tt = strv_join(info.argv, " "); tt = strv_join(info.argv, " ");
@ -2129,7 +2129,7 @@ int show(int argc, char *argv[], void *userdata) {
return r; return r;
STRV_FOREACH(name, names) { STRV_FOREACH(name, names) {
_cleanup_free_ char *path; _cleanup_free_ char *path = NULL;
path = unit_dbus_path_from_name(*name); path = unit_dbus_path_from_name(*name);
if (!path) if (!path)

View File

@ -199,6 +199,7 @@ int sd_dhcp_client_set_fallback_lease_lifetime(
int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v); int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v);
int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v); int sd_dhcp_client_add_vendor_option(sd_dhcp_client *client, sd_dhcp_option *v);
int sd_dhcp_client_is_running(const sd_dhcp_client *client);
int sd_dhcp_client_stop(sd_dhcp_client *client); int sd_dhcp_client_stop(sd_dhcp_client *client);
int sd_dhcp_client_start(sd_dhcp_client *client); int sd_dhcp_client_start(sd_dhcp_client *client);
int sd_dhcp_client_send_release(sd_dhcp_client *client); int sd_dhcp_client_send_release(sd_dhcp_client *client);

View File

@ -137,7 +137,7 @@ static int generate_unit_file(SysvStub *s) {
path_escaped); path_escaped);
if (s->description) { if (s->description) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = specifier_escape(s->description); t = specifier_escape(s->description);
if (!t) if (!t)
@ -165,7 +165,7 @@ static int generate_unit_file(SysvStub *s) {
yes_no(!s->pid_file)); yes_no(!s->pid_file));
if (s->pid_file) { if (s->pid_file) {
_cleanup_free_ char *t; _cleanup_free_ char *t = NULL;
t = specifier_escape(s->pid_file); t = specifier_escape(s->pid_file);
if (!t) if (!t)
@ -419,7 +419,7 @@ static int handle_dependencies(SysvStub *s, unsigned line, const char *full_text
} }
static int load_sysv(SysvStub *s) { static int load_sysv(SysvStub *s) {
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f = NULL;
unsigned line = 0; unsigned line = 0;
int r; int r;
enum { enum {

View File

@ -179,7 +179,7 @@ static int clock_state_update(
} }
static int run(int argc, char * argv[]) { static int run(int argc, char * argv[]) {
_cleanup_(sd_event_unrefp) sd_event *event; _cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(clock_state_release) ClockState state = { _cleanup_(clock_state_release) ClockState state = {
.timerfd_fd = -1, .timerfd_fd = -1,
.inotify_fd = -1, .inotify_fd = -1,

View File

@ -289,7 +289,7 @@ static int wall_tty_block(void) {
} }
static int process_password_files(void) { static int process_password_files(void) {
_cleanup_closedir_ DIR *d; _cleanup_closedir_ DIR *d = NULL;
struct dirent *de; struct dirent *de;
int r = 0; int r = 0;

View File

@ -106,7 +106,7 @@ static int get_file_options(const char *vendor, const char *model,
int *argc, char ***newargv) { int *argc, char ***newargv) {
_cleanup_free_ char *vendor_in = NULL, *model_in = NULL, *options_in = NULL; /* read in from file */ _cleanup_free_ char *vendor_in = NULL, *model_in = NULL, *options_in = NULL; /* read in from file */
_cleanup_strv_free_ char **options_argv = NULL; _cleanup_strv_free_ char **options_argv = NULL;
_cleanup_fclose_ FILE *f; _cleanup_fclose_ FILE *f = NULL;
int lineno, r; int lineno, r;
f = fopen(config_file, "re"); f = fopen(config_file, "re");

View File

@ -146,7 +146,7 @@ static int keyboard_load_and_wait(const char *vc, const char *map, const char *m
args[i++] = NULL; args[i++] = NULL;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *cmd; _cleanup_free_ char *cmd = NULL;
cmd = strv_join((char**) args, " "); cmd = strv_join((char**) args, " ");
log_debug("Executing \"%s\"...", strnull(cmd)); log_debug("Executing \"%s\"...", strnull(cmd));
@ -189,7 +189,7 @@ static int font_load_and_wait(const char *vc, const char *font, const char *map,
args[i++] = NULL; args[i++] = NULL;
if (DEBUG_LOGGING) { if (DEBUG_LOGGING) {
_cleanup_free_ char *cmd; _cleanup_free_ char *cmd = NULL;
cmd = strv_join((char**) args, " "); cmd = strv_join((char**) args, " ");
log_debug("Executing \"%s\"...", strnull(cmd)); log_debug("Executing \"%s\"...", strnull(cmd));