mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
This commit is contained in:
@@ -660,7 +660,7 @@ int cg_remove_xattr(const char *controller, const char *path, const char *name)
|
||||
|
||||
int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
const char *fs, *controller_str;
|
||||
const char *fs, *controller_str = NULL; /* silence gcc warning about unitialized variable */
|
||||
int unified, r;
|
||||
|
||||
assert(pid >= 0);
|
||||
@@ -720,6 +720,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||
continue;
|
||||
*e = 0;
|
||||
|
||||
assert(controller_str);
|
||||
r = string_contains_word(l, ",", controller_str);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -515,10 +515,10 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
||||
ALTERNATE_VALUE,
|
||||
} state = WORD;
|
||||
|
||||
const char *e, *word = format, *test_value;
|
||||
const char *e, *word = format, *test_value = NULL; /* test_value is initialized to appease gcc */
|
||||
char *k;
|
||||
_cleanup_free_ char *r = NULL;
|
||||
size_t i, len;
|
||||
size_t i, len = 0; /* len is initialized to appease gcc */
|
||||
int nest = 0;
|
||||
|
||||
assert(format);
|
||||
@@ -581,13 +581,12 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
|
||||
word = e+1;
|
||||
state = WORD;
|
||||
} else if (*e == ':') {
|
||||
if (!(flags & REPLACE_ENV_ALLOW_EXTENDED))
|
||||
if (flags & REPLACE_ENV_ALLOW_EXTENDED) {
|
||||
len = e - word - 2;
|
||||
state = TEST;
|
||||
} else
|
||||
/* Treat this as unsupported syntax, i.e. do no replacement */
|
||||
state = WORD;
|
||||
else {
|
||||
len = e-word-2;
|
||||
state = TEST;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ int write_string_stream_ts(
|
||||
const struct timespec *ts) {
|
||||
|
||||
bool needs_nl;
|
||||
int r, fd;
|
||||
int r, fd = -1;
|
||||
|
||||
assert(f);
|
||||
assert(line);
|
||||
@@ -140,8 +140,8 @@ int write_string_stream_ts(
|
||||
needs_nl = !(flags & WRITE_STRING_FILE_AVOID_NEWLINE) && !endswith(line, "\n");
|
||||
|
||||
if (needs_nl && (flags & WRITE_STRING_FILE_DISABLE_BUFFER)) {
|
||||
/* If STDIO buffering was disabled, then let's append the newline character to the string itself, so
|
||||
* that the write goes out in one go, instead of two */
|
||||
/* If STDIO buffering was disabled, then let's append the newline character to the string
|
||||
* itself, so that the write goes out in one go, instead of two */
|
||||
|
||||
line = strjoina(line, "\n");
|
||||
needs_nl = false;
|
||||
@@ -164,6 +164,7 @@ int write_string_stream_ts(
|
||||
if (ts) {
|
||||
const struct timespec twice[2] = {*ts, *ts};
|
||||
|
||||
assert(fd >= 0);
|
||||
if (futimens(fd, twice) < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "macro.h"
|
||||
#include "missing_network.h"
|
||||
#include "missing_socket.h"
|
||||
@@ -264,7 +265,7 @@ static inline int getsockopt_int(int fd, int level, int optname, int *ret) {
|
||||
socklen_t sl = sizeof(v);
|
||||
|
||||
if (getsockopt(fd, level, optname, &v, &sl) < 0)
|
||||
return -errno;
|
||||
return negative_errno();
|
||||
if (sl != sizeof(v))
|
||||
return -EIO;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user