diff options
author | Harald Hoyer <harald@redhat.com> | 2015-03-27 12:02:49 +0100 |
---|---|---|
committer | Harald Hoyer <harald@redhat.com> | 2015-03-27 14:57:38 +0100 |
commit | a7f7d1bde43fc825c49afea3f946f5b4b3d563e0 (patch) | |
tree | e6202adf568f95dbf22d7fb0c51f8c9220a56964 /src/shared | |
parent | 47d45d3cde45d6545367570264e4e3636bc9e345 (diff) |
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;
^
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/base-filesystem.c | 2 | ||||
-rw-r--r-- | src/shared/btrfs-util.c | 2 | ||||
-rw-r--r-- | src/shared/capability.c | 2 | ||||
-rw-r--r-- | src/shared/copy.c | 6 | ||||
-rw-r--r-- | src/shared/install.c | 2 | ||||
-rw-r--r-- | src/shared/logs-show.c | 2 | ||||
-rw-r--r-- | src/shared/util.c | 4 |
7 files changed, 10 insertions, 10 deletions
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c index 6bd317f354..11e0947407 100644 --- a/src/shared/base-filesystem.c +++ b/src/shared/base-filesystem.c @@ -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) diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index 62b1eff6ae..a95cb8394f 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -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 */ diff --git a/src/shared/capability.c b/src/shared/capability.c index 4840c3ebf4..58f00e6dae 100644 --- a/src/shared/capability.c +++ b/src/shared/capability.c @@ -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) diff --git a/src/shared/copy.c b/src/shared/copy.c index 9e4c3b0f72..775a339856 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -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); diff --git a/src/shared/install.c b/src/shared/install.c index 9c680a761b..1cc999b4d3 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -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); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 5a3ab3da3e..4e1b87814b 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -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 */ diff --git a/src/shared/util.c b/src/shared/util.c index 8b76531d4f..605fffcb7a 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -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); |