tree-wide: some more [static] related fixes
let's add [static] where it was missing so far Drop [static] on parameters that can be NULL. Add an assert() around parameters that have [static] and can't be NULL hence. Add some "const" where it was forgotten.
This commit is contained in:
parent
6fb0569065
commit
2caa38e99f
|
@ -455,12 +455,13 @@ static int setup_input(
|
||||||
const ExecContext *context,
|
const ExecContext *context,
|
||||||
const ExecParameters *params,
|
const ExecParameters *params,
|
||||||
int socket_fd,
|
int socket_fd,
|
||||||
int named_iofds[3]) {
|
const int named_iofds[static 3]) {
|
||||||
|
|
||||||
ExecInput i;
|
ExecInput i;
|
||||||
|
|
||||||
assert(context);
|
assert(context);
|
||||||
assert(params);
|
assert(params);
|
||||||
|
assert(named_iofds);
|
||||||
|
|
||||||
if (params->stdin_fd >= 0) {
|
if (params->stdin_fd >= 0) {
|
||||||
if (dup2(params->stdin_fd, STDIN_FILENO) < 0)
|
if (dup2(params->stdin_fd, STDIN_FILENO) < 0)
|
||||||
|
@ -570,7 +571,7 @@ static int setup_output(
|
||||||
const ExecParameters *params,
|
const ExecParameters *params,
|
||||||
int fileno,
|
int fileno,
|
||||||
int socket_fd,
|
int socket_fd,
|
||||||
int named_iofds[3],
|
const int named_iofds[static 3],
|
||||||
const char *ident,
|
const char *ident,
|
||||||
uid_t uid,
|
uid_t uid,
|
||||||
gid_t gid,
|
gid_t gid,
|
||||||
|
@ -2721,9 +2722,7 @@ out:
|
||||||
static void append_socket_pair(int *array, size_t *n, const int pair[static 2]) {
|
static void append_socket_pair(int *array, size_t *n, const int pair[static 2]) {
|
||||||
assert(array);
|
assert(array);
|
||||||
assert(n);
|
assert(n);
|
||||||
|
assert(pair);
|
||||||
if (!pair)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pair[0] >= 0)
|
if (pair[0] >= 0)
|
||||||
array[(*n)++] = pair[0];
|
array[(*n)++] = pair[0];
|
||||||
|
@ -2914,7 +2913,7 @@ static int exec_child(
|
||||||
ExecRuntime *runtime,
|
ExecRuntime *runtime,
|
||||||
DynamicCreds *dcreds,
|
DynamicCreds *dcreds,
|
||||||
int socket_fd,
|
int socket_fd,
|
||||||
int named_iofds[3],
|
const int named_iofds[static 3],
|
||||||
int *fds,
|
int *fds,
|
||||||
size_t n_socket_fds,
|
size_t n_socket_fds,
|
||||||
size_t n_storage_fds,
|
size_t n_storage_fds,
|
||||||
|
@ -3782,7 +3781,7 @@ static int exec_child(
|
||||||
}
|
}
|
||||||
|
|
||||||
static int exec_context_load_environment(const Unit *unit, const ExecContext *c, char ***l);
|
static int exec_context_load_environment(const Unit *unit, const ExecContext *c, char ***l);
|
||||||
static int exec_context_named_iofds(const ExecContext *c, const ExecParameters *p, int named_iofds[3]);
|
static int exec_context_named_iofds(const ExecContext *c, const ExecParameters *p, int named_iofds[static 3]);
|
||||||
|
|
||||||
int exec_spawn(Unit *unit,
|
int exec_spawn(Unit *unit,
|
||||||
ExecCommand *command,
|
ExecCommand *command,
|
||||||
|
@ -4110,13 +4109,18 @@ const char* exec_context_fdname(const ExecContext *c, int fd_index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int exec_context_named_iofds(const ExecContext *c, const ExecParameters *p, int named_iofds[static 3]) {
|
static int exec_context_named_iofds(
|
||||||
|
const ExecContext *c,
|
||||||
|
const ExecParameters *p,
|
||||||
|
int named_iofds[static 3]) {
|
||||||
|
|
||||||
size_t i, targets;
|
size_t i, targets;
|
||||||
const char* stdio_fdname[3];
|
const char* stdio_fdname[3];
|
||||||
size_t n_fds;
|
size_t n_fds;
|
||||||
|
|
||||||
assert(c);
|
assert(c);
|
||||||
assert(p);
|
assert(p);
|
||||||
|
assert(named_iofds);
|
||||||
|
|
||||||
targets = (c->std_input == EXEC_INPUT_NAMED_FD) +
|
targets = (c->std_input == EXEC_INPUT_NAMED_FD) +
|
||||||
(c->std_output == EXEC_OUTPUT_NAMED_FD) +
|
(c->std_output == EXEC_OUTPUT_NAMED_FD) +
|
||||||
|
|
|
@ -1699,7 +1699,7 @@ int setup_tmp_dirs(const char *id, char **tmp_dir, char **var_tmp_dir) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setup_netns(int netns_storage_socket[static 2]) {
|
int setup_netns(const int netns_storage_socket[static 2]) {
|
||||||
_cleanup_close_ int netns = -1;
|
_cleanup_close_ int netns = -1;
|
||||||
int r, q;
|
int r, q;
|
||||||
|
|
||||||
|
@ -1762,7 +1762,7 @@ fail:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int open_netns_path(int netns_storage_socket[static 2], const char *path) {
|
int open_netns_path(const int netns_storage_socket[static 2], const char *path) {
|
||||||
_cleanup_close_ int netns = -1;
|
_cleanup_close_ int netns = -1;
|
||||||
int q, r;
|
int q, r;
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ int setup_tmp_dirs(
|
||||||
char **tmp_dir,
|
char **tmp_dir,
|
||||||
char **var_tmp_dir);
|
char **var_tmp_dir);
|
||||||
|
|
||||||
int setup_netns(int netns_storage_socket[static 2]);
|
int setup_netns(const int netns_storage_socket[static 2]);
|
||||||
int open_netns_path(int netns_storage_socket[static 2], const char *path);
|
int open_netns_path(const int netns_storage_socket[static 2], const char *path);
|
||||||
|
|
||||||
const char* protect_home_to_string(ProtectHome p) _const_;
|
const char* protect_home_to_string(ProtectHome p) _const_;
|
||||||
ProtectHome protect_home_from_string(const char *s) _pure_;
|
ProtectHome protect_home_from_string(const char *s) _pure_;
|
||||||
|
|
|
@ -899,6 +899,8 @@ static int wireguard_read_key_file(const char *filename, uint8_t dest[static WG_
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
assert(dest);
|
||||||
|
|
||||||
r = read_full_file_full(filename, READ_FULL_FILE_SECURE | READ_FULL_FILE_UNBASE64, &key, &key_len);
|
r = read_full_file_full(filename, READ_FULL_FILE_SECURE | READ_FULL_FILE_UNBASE64, &key, &key_len);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -660,6 +660,8 @@ int efi_set_boot_order(uint16_t *order, size_t n) {
|
||||||
static int boot_id_hex(const char s[static 4]) {
|
static int boot_id_hex(const char s[static 4]) {
|
||||||
int id = 0, i;
|
int id = 0, i;
|
||||||
|
|
||||||
|
assert(s);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
if (s[i] >= '0' && s[i] <= '9')
|
if (s[i] >= '0' && s[i] <= '9')
|
||||||
id |= (s[i] - '0') << (3 - i) * 4;
|
id |= (s[i] - '0') << (3 - i) * 4;
|
||||||
|
|
|
@ -652,6 +652,8 @@ int ethtool_set_glinksettings(
|
||||||
struct ifreq ifr = {};
|
struct ifreq ifr = {};
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
assert(advertise);
|
||||||
|
|
||||||
if (autonegotiation != AUTONEG_DISABLE && memeqzero(advertise, sizeof(uint32_t) * N_ADVERTISE)) {
|
if (autonegotiation != AUTONEG_DISABLE && memeqzero(advertise, sizeof(uint32_t) * N_ADVERTISE)) {
|
||||||
log_info("ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.");
|
log_info("ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -3021,6 +3021,8 @@ static enum action verb_to_action(const char *verb) {
|
||||||
static const char** make_extra_args(const char *extra_args[static 4]) {
|
static const char** make_extra_args(const char *extra_args[static 4]) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
|
assert(extra_args);
|
||||||
|
|
||||||
if (arg_scope != UNIT_FILE_SYSTEM)
|
if (arg_scope != UNIT_FILE_SYSTEM)
|
||||||
extra_args[n++] = "--user";
|
extra_args[n++] = "--user";
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,9 @@ static int append_vendor_model(
|
||||||
const struct scsi_id_device *dev_scsi,
|
const struct scsi_id_device *dev_scsi,
|
||||||
char buf[static VENDOR_LENGTH + MODEL_LENGTH]) {
|
char buf[static VENDOR_LENGTH + MODEL_LENGTH]) {
|
||||||
|
|
||||||
|
assert(dev_scsi);
|
||||||
|
assert(buf);
|
||||||
|
|
||||||
if (strnlen(dev_scsi->vendor, VENDOR_LENGTH) != VENDOR_LENGTH)
|
if (strnlen(dev_scsi->vendor, VENDOR_LENGTH) != VENDOR_LENGTH)
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
"%s: bad vendor string \"%s\"",
|
"%s: bad vendor string \"%s\"",
|
||||||
|
|
|
@ -156,6 +156,7 @@ static int get_subst_type(const char **str, bool strict, FormatSubstitutionType
|
||||||
assert(str);
|
assert(str);
|
||||||
assert(*str);
|
assert(*str);
|
||||||
assert(ret_type);
|
assert(ret_type);
|
||||||
|
assert(ret_attr);
|
||||||
|
|
||||||
if (*p == '$') {
|
if (*p == '$') {
|
||||||
p++;
|
p++;
|
||||||
|
|
|
@ -1464,6 +1464,8 @@ static int attr_subst_subdir(char attr[static UTIL_PATH_SIZE]) {
|
||||||
const char *tail;
|
const char *tail;
|
||||||
size_t len, size;
|
size_t len, size;
|
||||||
|
|
||||||
|
assert(attr);
|
||||||
|
|
||||||
tail = strstr(attr, "/*/");
|
tail = strstr(attr, "/*/");
|
||||||
if (!tail)
|
if (!tail)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue