summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-01-22 02:18:59 +0100
committerLennart Poettering <lennart@poettering.net>2011-01-22 02:19:16 +0100
commitbd40a2d830265cdd36eb19576bdbe8e41dd527ee (patch)
tree65be055210412b9b3b961a153e7dc131ee7c653e /src
parent0b1724894fb85aa1c07b2619e9269cfafd736956 (diff)
clang: fix some issues found with clang-analyzersystemd/v17
Diffstat (limited to 'src')
-rw-r--r--src/cgroup.c5
-rw-r--r--src/cryptsetup.c1
-rw-r--r--src/load-fragment.c34
-rw-r--r--src/manager.c3
-rw-r--r--src/pam-module.c4
-rw-r--r--src/swap.c2
-rw-r--r--src/sysctl.c1
-rw-r--r--src/systemctl.c6
-rw-r--r--src/tmpfiles.c28
9 files changed, 42 insertions, 42 deletions
diff --git a/src/cgroup.c b/src/cgroup.c
index 64082d0dc6..392736f987 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -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;
diff --git a/src/cryptsetup.c b/src/cryptsetup.c
index f543a05055..c80572aed9 100644
--- a/src/cryptsetup.c
+++ b/src/cryptsetup.c
@@ -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")) {
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 44b2cf06c1..acceb9b51f 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -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;
}
diff --git a/src/manager.c b/src/manager.c
index 013b26b6c9..2714df1152 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -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 &&
diff --git a/src/pam-module.c b/src/pam-module.c
index 52507a4cbd..fc3aac185d 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -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]);
diff --git a/src/swap.c b/src/swap.c
index 23a98dd63f..9a253beea2 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -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 */
diff --git a/src/sysctl.c b/src/sysctl.c
index 38ea2d18bc..a8a9422ac3 100644
--- a/src/sysctl.c
+++ b/src/sysctl.c
@@ -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);
diff --git a/src/systemctl.c b/src/systemctl.c
index fb3430048c..8cdc01aa49 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -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;
diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index 984eaf0de1..d242dac7dc 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -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;