fix gcc warnings about uninitialized variables

like:

src/shared/install.c: In function ‘unit_file_lookup_state’:
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
         return r < 0 ? r : state;
                ^
src/shared/install.c:1796:13: note: ‘r’ was declared here
         int r;
             ^
This commit is contained in:
Harald Hoyer
2015-03-27 14:57:38 +01:00
parent 47d45d3cde
commit a7f7d1bde4
27 changed files with 37 additions and 37 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ static const BaseFilesystem table[] = {
int base_filesystem_create(const char *root) {
_cleanup_close_ int fd = -1;
unsigned i;
int r;
int r = 0;
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
if (fd < 0)
+1 -1
View File
@@ -717,7 +717,7 @@ int btrfs_resize_loopback_fd(int fd, uint64_t new_size, bool grow_only) {
_cleanup_free_ char *p = NULL, *loop = NULL, *backing = NULL;
_cleanup_close_ int loop_fd = -1, backing_fd = -1;
struct stat st;
dev_t dev;
dev_t dev = 0;
int r;
/* btrfs cannot handle file systems < 16M, hence use this as minimum */
+1 -1
View File
@@ -50,7 +50,7 @@ unsigned long cap_last_cap(void) {
static thread_local unsigned long saved;
static thread_local bool valid = false;
_cleanup_free_ char *content = NULL;
unsigned long p;
unsigned long p = 0;
int r;
if (valid)
+3 -3
View File
@@ -360,7 +360,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
}
int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags) {
int fdt, r;
int fdt = -1, r;
assert(from);
assert(to);
@@ -390,7 +390,7 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned
}
int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags) {
_cleanup_free_ char *t;
_cleanup_free_ char *t = NULL;
int r;
assert(from);
@@ -421,7 +421,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
int copy_times(int fdf, int fdt) {
struct timespec ut[2];
struct stat st;
usec_t crtime;
usec_t crtime = 0;
assert(fdf >= 0);
assert(fdt >= 0);
+1 -1
View File
@@ -1793,7 +1793,7 @@ UnitFileState unit_file_lookup_state(
UnitFileState state = _UNIT_FILE_STATE_INVALID;
char **i;
_cleanup_free_ char *path = NULL;
int r;
int r = 0;
assert(paths);
+1 -1
View File
@@ -990,7 +990,7 @@ static int show_journal(FILE *f,
if (warn_cutoff && line < how_many && not_before > 0) {
sd_id128_t boot_id;
usec_t cutoff;
usec_t cutoff = 0;
/* Check whether the cutoff line is too early */
+2 -2
View File
@@ -2882,7 +2882,7 @@ int getttyname_malloc(int fd, char **ret) {
int getttyname_harder(int fd, char **r) {
int k;
char *s;
char *s = NULL;
k = getttyname_malloc(fd, &s);
if (k < 0)
@@ -3435,7 +3435,7 @@ char **replace_env_argv(char **argv, char **env) {
/* If $FOO appears as single word, replace it by the split up variable */
if ((*i)[0] == '$' && (*i)[1] != '{') {
char *e;
char **w, **m;
char **w, **m = NULL;
unsigned q;
e = strv_env_get(env, *i+1);