Skip to content

Commit

Permalink
ovl: fix bogus -Wmaybe-unitialized warning
Browse files Browse the repository at this point in the history
gcc gets a bit confused by the logic in ovl_setup_trap() and
can't figure out whether the local 'trap' variable in the caller
was initialized or not:

fs/overlayfs/super.c: In function 'ovl_fill_super':
fs/overlayfs/super.c:1333:4: error: 'trap' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    iput(trap);
    ^~~~~~~~~~
fs/overlayfs/super.c:1312:17: note: 'trap' was declared here

Reword slightly to make it easier for the compiler to understand.

Fixes: 146d62e ("ovl: detect overlapping layers")
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
arndb authored and Miklos Szeredi committed Jun 18, 2019
1 parent 9179c21 commit 1dac6f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,8 @@ static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
int err;

trap = ovl_get_trap_inode(sb, dir);
err = PTR_ERR(trap);
if (IS_ERR(trap)) {
err = PTR_ERR_OR_ZERO(trap);
if (err) {
if (err == -ELOOP)
pr_err("overlayfs: conflicting %s path\n", name);
return err;
Expand Down

0 comments on commit 1dac6f5

Please sign in to comment.