mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
clang: fix some issues found with clang-analyzer
This commit is contained in:
parent
0b1724894f
commit
bd40a2d830
@ -404,17 +404,16 @@ char *cgroup_bonding_to_string(CGroupBonding *b) {
|
||||
pid_t cgroup_bonding_search_main_pid(CGroupBonding *b) {
|
||||
FILE *f;
|
||||
pid_t pid = 0, npid;
|
||||
int r;
|
||||
|
||||
assert(b);
|
||||
|
||||
if (!b->ours)
|
||||
return 0;
|
||||
|
||||
if ((r = cg_enumerate_processes(b->controller, b->path, &f)) < 0)
|
||||
if (cg_enumerate_processes(b->controller, b->path, &f) < 0)
|
||||
return 0;
|
||||
|
||||
while ((r = cg_read_pid(f, &npid)) > 0) {
|
||||
while (cg_read_pid(f, &npid) > 0) {
|
||||
|
||||
if (npid == pid)
|
||||
continue;
|
||||
|
@ -386,6 +386,7 @@ int main(int argc, char *argv[]) {
|
||||
if (try >= opt_tries) {
|
||||
log_error("Too many attempts.");
|
||||
r = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
} else if (streq(argv[1], "detach")) {
|
||||
|
@ -191,7 +191,6 @@ static int config_parse_listen(
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
int r;
|
||||
SocketPort *p;
|
||||
Socket *s;
|
||||
|
||||
@ -217,7 +216,7 @@ static int config_parse_listen(
|
||||
} else {
|
||||
p->type = SOCKET_SOCKET;
|
||||
|
||||
if ((r = socket_address_parse(&p->address, rvalue)) < 0) {
|
||||
if (socket_address_parse(&p->address, rvalue) < 0) {
|
||||
log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue);
|
||||
free(p);
|
||||
return 0;
|
||||
@ -289,14 +288,14 @@ static int config_parse_nice(
|
||||
void *userdata) {
|
||||
|
||||
ExecContext *c = data;
|
||||
int priority, r;
|
||||
int priority;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atoi(rvalue, &priority)) < 0) {
|
||||
if (safe_atoi(rvalue, &priority) < 0) {
|
||||
log_error("[%s:%u] Failed to parse nice priority, ignoring: %s. ", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -322,14 +321,14 @@ static int config_parse_oom_score_adjust(
|
||||
void *userdata) {
|
||||
|
||||
ExecContext *c = data;
|
||||
int oa, r;
|
||||
int oa;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atoi(rvalue, &oa)) < 0) {
|
||||
if (safe_atoi(rvalue, &oa) < 0) {
|
||||
log_error("[%s:%u] Failed to parse the OOM score adjust value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -506,14 +505,13 @@ static int config_parse_usec(
|
||||
void *userdata) {
|
||||
|
||||
usec_t *usec = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = parse_usec(rvalue, usec)) < 0) {
|
||||
if (parse_usec(rvalue, usec) < 0) {
|
||||
log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -893,14 +891,13 @@ static int config_parse_timer_slack_nsec(
|
||||
|
||||
ExecContext *c = data;
|
||||
unsigned long u;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atolu(rvalue, &u)) < 0) {
|
||||
if (safe_atolu(rvalue, &u) < 0) {
|
||||
log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -928,7 +925,7 @@ static int config_parse_limit(
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atollu(rvalue, &u)) < 0) {
|
||||
if (safe_atollu(rvalue, &u) < 0) {
|
||||
log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -985,14 +982,14 @@ static int config_parse_sysv_priority(
|
||||
void *userdata) {
|
||||
|
||||
int *priority = data;
|
||||
int r, i;
|
||||
int i;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) {
|
||||
if (safe_atoi(rvalue, &i) < 0 || i < 0) {
|
||||
log_error("[%s:%u] Failed to parse SysV start priority, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -1012,14 +1009,14 @@ static int config_parse_fsck_passno(
|
||||
void *userdata) {
|
||||
|
||||
int *passno = data;
|
||||
int r, i;
|
||||
int i;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) {
|
||||
if (safe_atoi(rvalue, &i) || i < 0) {
|
||||
log_error("[%s:%u] Failed to parse fsck pass number, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -1104,7 +1101,6 @@ static int config_parse_timer(
|
||||
|
||||
Timer *t = data;
|
||||
usec_t u;
|
||||
int r;
|
||||
TimerValue *v;
|
||||
TimerBase b;
|
||||
|
||||
@ -1118,7 +1114,7 @@ static int config_parse_timer(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((r = parse_usec(rvalue, &u)) < 0) {
|
||||
if (parse_usec(rvalue, &u) < 0) {
|
||||
log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
@ -1379,7 +1375,6 @@ static int config_parse_env_file(
|
||||
if (feof(f))
|
||||
break;
|
||||
|
||||
r = -errno;
|
||||
log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue);
|
||||
r = 0;
|
||||
goto finish;
|
||||
@ -1431,7 +1426,6 @@ static int config_parse_ip_tos(
|
||||
void *userdata) {
|
||||
|
||||
int *ip_tos = data, x;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
@ -1439,7 +1433,7 @@ static int config_parse_ip_tos(
|
||||
assert(data);
|
||||
|
||||
if ((x = ip_tos_from_string(rvalue)) < 0)
|
||||
if ((r = safe_atoi(rvalue, &x)) < 0) {
|
||||
if (safe_atoi(rvalue, &x) < 0) {
|
||||
log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2428,7 +2428,6 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
|
||||
union sockaddr_union sa;
|
||||
int n = 0;
|
||||
char *message = NULL;
|
||||
ssize_t r;
|
||||
|
||||
/* Don't generate plymouth events if the service was already
|
||||
* started and we're just deserializing */
|
||||
@ -2472,7 +2471,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if ((r = write(fd, message, n + 1)) != n + 1) {
|
||||
if (write(fd, message, n + 1) != n + 1) {
|
||||
|
||||
if (errno != EPIPE &&
|
||||
errno != EAGAIN &&
|
||||
|
@ -46,7 +46,9 @@ static int parse_argv(pam_handle_t *handle,
|
||||
char ***controllers) {
|
||||
|
||||
unsigned i;
|
||||
#if 0
|
||||
bool controller_set = false;
|
||||
#endif
|
||||
|
||||
assert(argc >= 0);
|
||||
assert(argc == 0 || argv);
|
||||
@ -104,7 +106,9 @@ static int parse_argv(pam_handle_t *handle,
|
||||
*controllers = l;
|
||||
}
|
||||
|
||||
#if 0
|
||||
controller_set = true;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
pam_syslog(handle, LOG_ERR, "Unknown parameter '%s'.", argv[i]);
|
||||
|
@ -1090,7 +1090,7 @@ int swap_fd_event(Manager *m, int events) {
|
||||
assert(m);
|
||||
assert(events & EPOLLPRI);
|
||||
|
||||
if ((r == swap_load_proc_swaps(m, true)) < 0) {
|
||||
if ((r = swap_load_proc_swaps(m, true)) < 0) {
|
||||
log_error("Failed to reread /proc/swaps: %s", strerror(-r));
|
||||
|
||||
/* Reset flags, just in case, for late calls */
|
||||
|
@ -43,6 +43,7 @@ static void apply_sysctl(const char *property, const char *value) {
|
||||
if (!(p = new(char, sizeof(PROC_SYS_PREFIX) + strlen(property)))) {
|
||||
log_error("Out of memory");
|
||||
exit_code = -ENOMEM;
|
||||
return;
|
||||
}
|
||||
|
||||
n = stpcpy(p, PROC_SYS_PREFIX);
|
||||
|
@ -502,8 +502,10 @@ static int list_units(DBusConnection *bus, char **args, unsigned n) {
|
||||
c++;
|
||||
}
|
||||
|
||||
qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
|
||||
output_units_list(unit_infos, c);
|
||||
if (c > 0) {
|
||||
qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
|
||||
output_units_list(unit_infos, c);
|
||||
}
|
||||
|
||||
r = 0;
|
||||
|
||||
|
@ -474,7 +474,7 @@ static void item_free(Item *i) {
|
||||
static int parse_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
|
||||
Item *i;
|
||||
char *mode = NULL, *user = NULL, *group = NULL, *age = NULL;
|
||||
int r, n;
|
||||
int r;
|
||||
|
||||
assert(fname);
|
||||
assert(line >= 1);
|
||||
@ -485,19 +485,19 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, cons
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if ((n = sscanf(buffer,
|
||||
"%c "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms",
|
||||
&i->type,
|
||||
&i->path,
|
||||
&mode,
|
||||
&user,
|
||||
&group,
|
||||
&age)) < 2) {
|
||||
if (sscanf(buffer,
|
||||
"%c "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms "
|
||||
"%ms",
|
||||
&i->type,
|
||||
&i->path,
|
||||
&mode,
|
||||
&user,
|
||||
&group,
|
||||
&age) < 2) {
|
||||
log_error("[%s:%u] Syntax error.", fname, line);
|
||||
r = -EIO;
|
||||
goto finish;
|
||||
|
Loading…
x
Reference in New Issue
Block a user