tree-wide: add missing assertions
Found by coccinelle.
This commit is contained in:
@@ -92,6 +92,10 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned level,
|
||||
UnitTimes *times;
|
||||
BootTimes *boot;
|
||||
|
||||
assert(bus);
|
||||
assert(name);
|
||||
assert(units);
|
||||
|
||||
if (strv_extend(units, name))
|
||||
return log_oom();
|
||||
|
||||
@@ -163,6 +167,7 @@ static int list_dependencies(sd_bus *bus, const char *name) {
|
||||
BootTimes *boot;
|
||||
|
||||
assert(bus);
|
||||
assert(name);
|
||||
|
||||
path = unit_dbus_path_from_name(name);
|
||||
if (!path)
|
||||
|
||||
@@ -96,6 +96,8 @@ static int mangle_patterns(char **args, char ***ret) {
|
||||
_cleanup_strv_free_ char **mangled = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
STRV_FOREACH(arg, args) {
|
||||
char *t;
|
||||
|
||||
|
||||
+1
-1
@@ -117,9 +117,9 @@ static int cat_config(char **files) {
|
||||
}
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
assert(ret_args);
|
||||
|
||||
OptionParser opts = { argc, argv };
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
assert(ret_args);
|
||||
|
||||
OptionParser opts = { argc, argv };
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
|
||||
_cleanup_close_ int pin_fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = sd_bus_new(&bus);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to allocate bus: %m");
|
||||
|
||||
+3
-1
@@ -162,10 +162,12 @@ static int bus_job_find(sd_bus *bus, const char *path, const char *interface, vo
|
||||
|
||||
static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *reterr_error) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
Manager *m = userdata;
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
unsigned k = 0;
|
||||
Job *j;
|
||||
|
||||
assert(nodes);
|
||||
|
||||
l = new0(char*, hashmap_size(m->jobs)+1);
|
||||
if (!l)
|
||||
return -ENOMEM;
|
||||
|
||||
+3
-1
@@ -413,10 +413,12 @@ static int bus_kill_context_find(sd_bus *bus, const char *path, const char *inte
|
||||
|
||||
static int bus_unit_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *reterr_error) {
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
Manager *m = userdata;
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
unsigned k = 0;
|
||||
Unit *u;
|
||||
|
||||
assert(nodes);
|
||||
|
||||
l = new0(char*, hashmap_size(m->units)+1);
|
||||
if (!l)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -174,6 +174,9 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
|
||||
0x8a, 0xbb, 0x39, 0x57, 0x8d, 0xd9, 0xec, 0x59
|
||||
};
|
||||
|
||||
assert(name);
|
||||
assert(ret_uid);
|
||||
|
||||
unsigned n_tries = 100, current_suggested = 0;
|
||||
int r;
|
||||
|
||||
|
||||
+40
-14
@@ -518,6 +518,7 @@ static int setup_output(
|
||||
|
||||
assert(context);
|
||||
assert(params);
|
||||
assert(named_iofds);
|
||||
assert(ident);
|
||||
assert(journal_stream_dev);
|
||||
assert(journal_stream_ino);
|
||||
@@ -684,6 +685,7 @@ static int setup_confirm_stdio(
|
||||
int r;
|
||||
|
||||
assert(context);
|
||||
assert(vc);
|
||||
assert(ret_saved_stdin);
|
||||
assert(ret_saved_stdout);
|
||||
|
||||
@@ -742,6 +744,7 @@ static void write_confirm_error(int err, const char *vc, const char *unit_id) {
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
assert(vc);
|
||||
assert(unit_id);
|
||||
|
||||
fd = open_terminal(vc, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
@@ -789,6 +792,7 @@ static int ask_for_confirmation(const ExecContext *context, const ExecParameters
|
||||
|
||||
assert(context);
|
||||
assert(params);
|
||||
assert(cmdline);
|
||||
|
||||
/* For any internal errors, assume a positive response. */
|
||||
r = setup_confirm_stdio(context, params->confirm_spawn, &saved_stdin, &saved_stdout);
|
||||
@@ -965,6 +969,8 @@ static int get_supplementary_groups(
|
||||
static int enforce_groups(gid_t gid, const gid_t *supplementary_gids, int ngids) {
|
||||
int r;
|
||||
|
||||
assert(supplementary_gids || ngids == 0);
|
||||
|
||||
/* Handle SupplementaryGroups= if it is not empty */
|
||||
if (ngids > 0) {
|
||||
r = maybe_setgroups(ngids, supplementary_gids);
|
||||
@@ -1063,6 +1069,7 @@ static int ask_password_conv(
|
||||
assert(msg);
|
||||
assert(data->context);
|
||||
assert(data->params);
|
||||
assert(ret);
|
||||
|
||||
size_t n = num_msg;
|
||||
struct pam_response *responses = new0(struct pam_response, n);
|
||||
@@ -1166,7 +1173,7 @@ static int attach_to_subcgroup(
|
||||
const ExecContext *context,
|
||||
const CGroupContext *cgroup_context,
|
||||
const ExecParameters *params,
|
||||
const char *prefix) {
|
||||
const char *prefix) { /* may be NULL */
|
||||
|
||||
_cleanup_free_ char *subgroup = NULL;
|
||||
int r;
|
||||
@@ -1300,6 +1307,7 @@ static int setup_pam(
|
||||
int flags = 0;
|
||||
|
||||
assert(context);
|
||||
assert(cgroup_context);
|
||||
assert(params);
|
||||
assert(user);
|
||||
assert(uid_is_valid(uid));
|
||||
@@ -1987,9 +1995,9 @@ static int build_environment(
|
||||
const ExecContext *c,
|
||||
const ExecParameters *p,
|
||||
const CGroupContext *cgroup_context,
|
||||
const char *home,
|
||||
const char *username,
|
||||
const char *shell,
|
||||
const char *home, /* may be NULL */
|
||||
const char *username, /* may be NULL */
|
||||
const char *shell, /* may be NULL */
|
||||
dev_t journal_stream_dev,
|
||||
ino_t journal_stream_ino,
|
||||
char *const *pressure_path,
|
||||
@@ -2005,6 +2013,7 @@ static int build_environment(
|
||||
assert(c);
|
||||
assert(p);
|
||||
assert(cgroup_context);
|
||||
assert(pressure_path);
|
||||
assert(ret);
|
||||
|
||||
exec_pid = needs_sandboxing && exec_needs_pid_namespace(c, p) ? 1 : getpid_cached();
|
||||
@@ -2307,6 +2316,7 @@ static int bpffs_prepare(
|
||||
_cleanup_close_pair_ int socket_fds[2] = EBADF_PAIR, errno_pipe[2] = EBADF_PAIR;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
assert(ret_sock_fd);
|
||||
assert(ret_pid);
|
||||
assert(ret_errno_pipe);
|
||||
@@ -2336,6 +2346,9 @@ static int bpffs_prepare(
|
||||
static int setup_private_users_child(int unshare_ready_fd, const char *uid_map, const char *gid_map, bool allow_setgroups) {
|
||||
int r;
|
||||
|
||||
assert(uid_map);
|
||||
assert(gid_map);
|
||||
|
||||
/* Child process, running in the original user namespace. Let's update the parent's UID/GID map from
|
||||
* here, after the parent opened its own user namespace. */
|
||||
|
||||
@@ -2373,7 +2386,7 @@ static int setup_private_users_child(int unshare_ready_fd, const char *uid_map,
|
||||
}
|
||||
|
||||
static int setup_private_users(
|
||||
sd_varlink *nsresource_link,
|
||||
sd_varlink *nsresource_link, /* may be NULL */
|
||||
PrivateUsers private_users,
|
||||
uid_t saved_uid, /* service manager uid */
|
||||
gid_t saved_gid, /* service manager gid */
|
||||
@@ -2703,6 +2716,7 @@ static int create_many_symlinks(const char *root, const char *source, char **sym
|
||||
_cleanup_free_ char *src_abs = NULL;
|
||||
int r;
|
||||
|
||||
assert(root);
|
||||
assert(source);
|
||||
|
||||
src_abs = path_join(root, source);
|
||||
@@ -3517,6 +3531,7 @@ static bool insist_on_sandboxing(
|
||||
size_t n_bind_mounts) {
|
||||
|
||||
assert(context);
|
||||
assert(rootfs);
|
||||
assert(n_bind_mounts == 0 || bind_mounts);
|
||||
|
||||
/* Checks whether we need to insist on fs namespacing. i.e. whether we have settings configured that
|
||||
@@ -3563,6 +3578,7 @@ static int setup_ephemeral(
|
||||
assert(context);
|
||||
assert(runtime);
|
||||
assert(rootfs);
|
||||
assert(reterr_path);
|
||||
|
||||
if (!rootfs->image && !rootfs->directory)
|
||||
return 0;
|
||||
@@ -3639,15 +3655,16 @@ static int setup_ephemeral(
|
||||
static int verity_settings_prepare(
|
||||
VeritySettings *verity,
|
||||
const char *root_image,
|
||||
const struct iovec *root_hash,
|
||||
const char *root_hash_path,
|
||||
const struct iovec *root_hash_sig,
|
||||
const char *root_hash_sig_path,
|
||||
const char *verity_data_path) {
|
||||
const struct iovec *root_hash, /* may be NULL */
|
||||
const char *root_hash_path, /* may be NULL */
|
||||
const struct iovec *root_hash_sig, /* may be NULL */
|
||||
const char *root_hash_sig_path, /* may be NULL */
|
||||
const char *verity_data_path) { /* may be NULL */
|
||||
|
||||
int r;
|
||||
|
||||
assert(verity);
|
||||
assert(root_image);
|
||||
|
||||
if (root_hash) {
|
||||
iovec_done(&verity->root_hash);
|
||||
@@ -3695,6 +3712,7 @@ static int pin_rootfs(
|
||||
assert(context);
|
||||
assert(params);
|
||||
assert(ret);
|
||||
assert(reterr_path);
|
||||
|
||||
if (!FLAGS_SET(params->flags, EXEC_APPLY_CHROOT)) {
|
||||
*ret = PINNED_RESOURCE_NULL;
|
||||
@@ -3841,7 +3859,7 @@ static int apply_mount_namespace(
|
||||
PidRef *bpffs_pidref,
|
||||
int bpffs_socket_fd,
|
||||
int bpffs_errno_pipe,
|
||||
sd_varlink *mountfsd_link,
|
||||
sd_varlink *mountfsd_link, /* may be NULL */
|
||||
char **reterr_path) {
|
||||
|
||||
_cleanup_(verity_settings_done) VeritySettings verity = VERITY_SETTINGS_DEFAULT;
|
||||
@@ -3859,6 +3877,10 @@ static int apply_mount_namespace(
|
||||
assert(context);
|
||||
assert(params);
|
||||
assert(runtime);
|
||||
assert(rootfs);
|
||||
assert(pressure_path);
|
||||
assert(bpffs_pidref);
|
||||
assert(reterr_path);
|
||||
|
||||
CLEANUP_ARRAY(bind_mounts, n_bind_mounts, bind_mount_free_many);
|
||||
|
||||
@@ -4091,8 +4113,8 @@ static int apply_working_directory(
|
||||
const ExecContext *context,
|
||||
const ExecParameters *params,
|
||||
ExecRuntime *runtime,
|
||||
const char *pwent_home,
|
||||
char * const *env) {
|
||||
const char *pwent_home, /* may be NULL */
|
||||
char * const *env) { /* can be NULL */
|
||||
|
||||
const char *wd;
|
||||
int r;
|
||||
@@ -4572,6 +4594,7 @@ static void log_command_line(
|
||||
assert(params);
|
||||
assert(msg);
|
||||
assert(executable);
|
||||
assert(argv);
|
||||
|
||||
if (!DEBUG_LOGGING)
|
||||
return;
|
||||
@@ -4691,7 +4714,7 @@ static int setup_delegated_namespaces(
|
||||
PidRef *bpffs_pidref,
|
||||
int bpffs_socket_fd,
|
||||
int bpffs_errno_pipe,
|
||||
sd_varlink *mountfsd_link,
|
||||
sd_varlink *mountfsd_link, /* may be NULL */
|
||||
int *reterr_exit_status) {
|
||||
|
||||
int r;
|
||||
@@ -4707,6 +4730,9 @@ static int setup_delegated_namespaces(
|
||||
assert(params);
|
||||
assert(runtime);
|
||||
assert(rootfs);
|
||||
assert(pressure_path);
|
||||
assert(command);
|
||||
assert(bpffs_pidref);
|
||||
assert(reterr_exit_status);
|
||||
|
||||
if (exec_needs_network_namespace(context) &&
|
||||
|
||||
@@ -2511,6 +2511,7 @@ static int exec_shared_runtime_make(
|
||||
assert(m);
|
||||
assert(c);
|
||||
assert(id);
|
||||
assert(ret);
|
||||
|
||||
/* It is not necessary to create ExecSharedRuntime object. */
|
||||
if (!c->user_namespace_path && !exec_needs_network_namespace(c) && !exec_needs_ipc_namespace(c) &&
|
||||
|
||||
@@ -198,6 +198,9 @@ static int manager_find_user_config_paths(char ***ret_files, char ***ret_dirs) {
|
||||
_cleanup_strv_free_ char **files = NULL, **dirs = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret_files);
|
||||
assert(ret_dirs);
|
||||
|
||||
r = xdg_user_config_dir("/systemd", &base);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -6923,6 +6923,8 @@ int unit_get_exec_quota_stats(Unit *u, ExecContext *c, ExecDirectoryType dt, uin
|
||||
|
||||
assert(u);
|
||||
assert(c);
|
||||
assert(ret_usage);
|
||||
assert(ret_limit);
|
||||
|
||||
if (c->directories[dt].n_items == 0) {
|
||||
*ret_usage = UINT64_MAX;
|
||||
|
||||
@@ -243,6 +243,12 @@ static int enumerate_dir_d(
|
||||
char *c;
|
||||
int r;
|
||||
|
||||
assert(top);
|
||||
assert(bottom);
|
||||
assert(drops);
|
||||
assert(toppath);
|
||||
assert(drop);
|
||||
|
||||
assert(!endswith(drop, "/"));
|
||||
|
||||
path = path_join(toppath, drop);
|
||||
|
||||
@@ -20,6 +20,8 @@ static int environment_dirs(char ***ret) {
|
||||
_cleanup_free_ char *c = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
dirs = strv_new(CONF_PATHS("environment.d"));
|
||||
if (!dirs)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -73,9 +73,11 @@ static int acquire_group_list(char ***ret) {
|
||||
}
|
||||
|
||||
static int group_completion_callback(const char *key, GetCompletionsFlags flags, char ***ret_list, void *userdata) {
|
||||
char ***available = userdata;
|
||||
char ***available = ASSERT_PTR(userdata);
|
||||
int r;
|
||||
|
||||
assert(ret_list);
|
||||
|
||||
if (!*available) {
|
||||
r = acquire_group_list(available);
|
||||
if (r < 0)
|
||||
|
||||
@@ -552,12 +552,14 @@ static void home_set_state(Home *h, HomeState state) {
|
||||
|
||||
static int home_parse_worker_stdout(int _fd, UserRecord **ret) {
|
||||
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
|
||||
_cleanup_close_ int fd = _fd; /* take possession, even on failure */
|
||||
_cleanup_close_ int fd = ASSERT_FD(TAKE_FD(_fd)); /* take possession, even on failure */
|
||||
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (fstat(fd, &st) < 0)
|
||||
return log_error_errno(errno, "Failed to stat stdout fd: %m");
|
||||
|
||||
|
||||
@@ -1370,6 +1370,7 @@ static int home_create(UserRecord *h, Hashmap *blobs, UserRecord **ret_home) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(ret_home);
|
||||
|
||||
if (!h->user_name)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "User record lacks name, refusing.");
|
||||
|
||||
@@ -1486,10 +1486,12 @@ static int transfer_node_enumerator(
|
||||
sd_bus_error *error) {
|
||||
|
||||
_cleanup_strv_free_ char **l = NULL;
|
||||
Manager *m = userdata;
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
Transfer *t;
|
||||
unsigned k = 0;
|
||||
|
||||
assert(nodes);
|
||||
|
||||
l = new0(char*, hashmap_size(m->transfers) + 1);
|
||||
if (!l)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -70,6 +70,8 @@ static const char *extra_option_163 = "private_option_163";
|
||||
static const char *extra_option_164 = "private_option_164";
|
||||
|
||||
static void setup(sd_event_io_handler_t io_handler, sd_dhcp_client_callback_t client_handler, sd_dhcp_client **ret) {
|
||||
assert_se(ret);
|
||||
|
||||
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
|
||||
ASSERT_OK(sd_event_new(&e));
|
||||
ASSERT_NOT_NULL(e);
|
||||
|
||||
@@ -141,6 +141,7 @@ int journal_directory_vacuum(
|
||||
CLEANUP_ARRAY(list, n_list, vacuum_info_array_free);
|
||||
|
||||
assert(directory);
|
||||
POINTER_MAY_BE_NULL(oldest_usec);
|
||||
|
||||
if (max_use <= 0 && max_retention_usec <= 0 && n_max_files <= 0)
|
||||
return 0;
|
||||
|
||||
@@ -3433,6 +3433,8 @@ _public_ int sd_journal_enumerate_unique(
|
||||
assert_return(j, -EINVAL);
|
||||
assert_return(!journal_origin_changed(j), -ECHILD);
|
||||
assert_return(j->unique_field, -EINVAL);
|
||||
assert_return(ret_data, -EINVAL);
|
||||
assert_return(ret_size, -EINVAL);
|
||||
|
||||
k = strlen(j->unique_field);
|
||||
|
||||
|
||||
@@ -1081,11 +1081,14 @@ int sd_netlink_message_read_strv(sd_netlink_message *m, uint16_t container_type,
|
||||
if (type != attr_type)
|
||||
continue;
|
||||
|
||||
if (ret) {
|
||||
r = strv_extend(&s, RTA_DATA(rta));
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
*ret = TAKE_PTR(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5318,6 +5318,15 @@ static int run_container(
|
||||
assert_se(sigemptyset(&mask_chld) == 0);
|
||||
assert_se(sigaddset(&mask_chld, SIGCHLD) == 0);
|
||||
|
||||
assert(runtime_dir);
|
||||
assert(directory);
|
||||
assert(veth_name);
|
||||
assert(veth_created);
|
||||
assert(expose_args);
|
||||
assert(master);
|
||||
assert(pid);
|
||||
assert(ret);
|
||||
|
||||
/* Set up the unix export host directory on the host first */
|
||||
r = setup_unix_export_dir_outside(runtime_dir, &unix_export_host_dir);
|
||||
if (r < 0)
|
||||
|
||||
@@ -184,6 +184,7 @@ static int print_path(const char *n) {
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
assert(ret_args);
|
||||
|
||||
OptionParser opts = { argc, argv };
|
||||
|
||||
|
||||
@@ -195,6 +195,9 @@ static int determine_matches(const char *image, char **l, bool allow_any, char *
|
||||
_cleanup_strv_free_ char **k = NULL;
|
||||
int r;
|
||||
|
||||
assert(image);
|
||||
assert(ret);
|
||||
|
||||
/* Determine the matches to apply. If the list is empty we derive the match from the image name. If
|
||||
* the list contains exactly the "-" we return a wildcard list (which is the empty list), but only if
|
||||
* this is expressly permitted. */
|
||||
|
||||
@@ -1532,6 +1532,7 @@ static int print_configuration(DNSConfiguration *configuration, StatusMode mode,
|
||||
int r;
|
||||
|
||||
assert(configuration);
|
||||
POINTER_MAY_BE_NULL(empty_line);
|
||||
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
|
||||
@@ -637,6 +637,10 @@ static int bus_append_exec_command(sd_bus_message *m, const char *field, const c
|
||||
ExecCommandFlags flags = 0;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(field);
|
||||
assert(eq);
|
||||
|
||||
do {
|
||||
switch (*eq) {
|
||||
|
||||
|
||||
@@ -2983,6 +2983,10 @@ static int normalize_linked_files(
|
||||
_cleanup_strv_free_ char **files = NULL, **names = NULL;
|
||||
int r;
|
||||
|
||||
assert(lp);
|
||||
assert(ret_names);
|
||||
assert(ret_files);
|
||||
|
||||
STRV_FOREACH(a, names_or_paths) {
|
||||
_cleanup_(install_context_done) InstallContext ctx = { .scope = scope };
|
||||
InstallInfo *i = NULL;
|
||||
|
||||
@@ -86,6 +86,8 @@ int get_keymaps(char ***ret) {
|
||||
_cleanup_strv_free_ char **keymap_dirs = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = keymap_directories(&keymap_dirs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -189,14 +189,14 @@ static int mcopy_flush_files(
|
||||
const char *dest_rel,
|
||||
char ***file_batch) {
|
||||
|
||||
_cleanup_strv_free_ char **argv = NULL, **batch = TAKE_PTR(*file_batch);
|
||||
_cleanup_free_ char *dest = NULL;
|
||||
|
||||
assert(mcopy_bin);
|
||||
assert(node);
|
||||
assert(dest_rel);
|
||||
assert(file_batch);
|
||||
|
||||
_cleanup_strv_free_ char **argv = NULL, **batch = TAKE_PTR(*file_batch);
|
||||
_cleanup_free_ char *dest = NULL;
|
||||
|
||||
if (strv_isempty(batch))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -9585,6 +9585,8 @@ int tpm2_pcrlock_policy_from_credentials(
|
||||
_cleanup_close_ int dfd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
/* During boot we'll not have access to the pcrlock.json file in /var/. In order to support
|
||||
* pcrlock-bound root file systems we'll store a copy of the JSON data, wrapped in an (plaintext)
|
||||
* credential in the ESP or XBOOTLDR partition. There might be multiple of those however (because of
|
||||
|
||||
@@ -384,6 +384,11 @@ int unit_file_build_name_map(
|
||||
uint64_t timestamp_hash;
|
||||
int r;
|
||||
|
||||
assert(lp);
|
||||
POINTER_MAY_BE_NULL(cache_timestamp_hash);
|
||||
assert(unit_ids_map);
|
||||
assert(unit_names_map);
|
||||
|
||||
/* Before doing anything, check if the timestamp hash that was passed is still valid.
|
||||
* If yes, do nothing. */
|
||||
if (cache_timestamp_hash &&
|
||||
@@ -635,6 +640,9 @@ int unit_file_remove_from_name_map(
|
||||
|
||||
int r;
|
||||
|
||||
assert(lp);
|
||||
assert(unit_ids_map);
|
||||
assert(unit_names_map);
|
||||
assert(path);
|
||||
|
||||
/* This assumes the specified path is already removed, and drops the relevant entries from the maps. */
|
||||
@@ -655,6 +663,7 @@ int unit_file_remove_from_name_map(
|
||||
_unused_ _cleanup_free_ char *key = NULL;
|
||||
free(hashmap_remove2(*unit_ids_map, name, (void**) &key));
|
||||
string_strv_hashmap_remove(*unit_names_map, name, name);
|
||||
if (path_cache)
|
||||
free(set_remove(*path_cache, path));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -369,8 +369,13 @@ static int acquire_device_list(
|
||||
sd_varlink **link,
|
||||
char ***ret_menu,
|
||||
char ***ret_accepted) {
|
||||
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
assert(ret_menu);
|
||||
assert(ret_accepted);
|
||||
|
||||
r = connect_to_repart(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -100,7 +100,7 @@ static bool output_show_machine(const char *name, char **patterns) {
|
||||
|
||||
static int get_machine_list(
|
||||
sd_bus *bus,
|
||||
struct machine_info **_machine_infos,
|
||||
struct machine_info **ret_machine_infos,
|
||||
char **patterns) {
|
||||
|
||||
struct machine_info *machine_infos = NULL;
|
||||
@@ -108,6 +108,9 @@ static int get_machine_list(
|
||||
_cleanup_free_ char *hn = NULL;
|
||||
int c = 0, r;
|
||||
|
||||
assert(bus);
|
||||
assert(ret_machine_infos);
|
||||
|
||||
hn = gethostname_malloc();
|
||||
if (!hn)
|
||||
return log_oom();
|
||||
@@ -153,7 +156,7 @@ static int get_machine_list(
|
||||
c++;
|
||||
}
|
||||
|
||||
*_machine_infos = machine_infos;
|
||||
*ret_machine_infos = machine_infos;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -519,8 +519,10 @@ int unit_find_paths(
|
||||
*/
|
||||
|
||||
assert(unit_name);
|
||||
assert(ret_fragment_path);
|
||||
assert(lp);
|
||||
assert(cached_id_map);
|
||||
assert(cached_name_map);
|
||||
assert(ret_fragment_path);
|
||||
|
||||
/* Go via the bus to acquire the path, unless we are explicitly told not to, or when the unit name is a template */
|
||||
if (!force_client_side &&
|
||||
@@ -529,6 +531,8 @@ int unit_find_paths(
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *load_state = NULL, *dbus_path = NULL;
|
||||
|
||||
assert(bus);
|
||||
|
||||
dbus_path = unit_dbus_path_from_name(unit_name);
|
||||
if (!dbus_path)
|
||||
return log_oom();
|
||||
|
||||
@@ -666,6 +666,8 @@ static int job_node_enumerator(
|
||||
Job *j;
|
||||
unsigned k = 0;
|
||||
|
||||
assert(nodes);
|
||||
|
||||
l = new0(char*, hashmap_size(m->jobs) + 1);
|
||||
if (!l)
|
||||
return -ENOMEM;
|
||||
@@ -759,6 +761,8 @@ static int sysupdate_run_simple(sd_json_variant **ret, Target *t, ...) {
|
||||
_cleanup_free_ char *target_arg = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (t) {
|
||||
r = target_get_argument(t, &target_arg);
|
||||
if (r < 0)
|
||||
@@ -1617,6 +1621,8 @@ static int target_node_enumerator(
|
||||
unsigned k = 0;
|
||||
int r;
|
||||
|
||||
assert(nodes);
|
||||
|
||||
r = manager_ensure_targets(m);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -19,6 +19,9 @@ static int open_passwd_file(const char *root, const char *fname, FILE **ret_file
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
|
||||
assert(fname);
|
||||
assert(ret_file);
|
||||
|
||||
fd = chase_and_open(fname, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, &p);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
@@ -42,6 +42,7 @@ static void test_resolve_one(const char *name) {
|
||||
static int parse_argv(int argc, char *argv[], char ***ret_args) {
|
||||
assert_se(argc >= 0);
|
||||
assert_se(argv);
|
||||
assert_se(ret_args);
|
||||
|
||||
OptionParser opts = { argc, argv };
|
||||
|
||||
|
||||
@@ -1824,6 +1824,8 @@ int udev_rules_load(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing
|
||||
_cleanup_strv_free_ char **directories = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret_rules);
|
||||
|
||||
rules = udev_rules_new(resolve_name_timing);
|
||||
if (!rules)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -378,6 +378,9 @@ int xdg_autostart_format_exec_start(
|
||||
bool first_arg;
|
||||
int r;
|
||||
|
||||
assert(exec);
|
||||
assert(ret_exec_start);
|
||||
|
||||
/*
|
||||
* Unfortunately, there is a mismatch between systemd's idea of $PATH and XDGs. I.e. we need to
|
||||
* ensure that we have an absolute path to support cases where $PATH has been modified from the
|
||||
|
||||
Reference in New Issue
Block a user