ovl: fix bogus -Wmaybe-unitialized warning

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: 146d62e5a5 ("ovl: detect overlapping layers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Arnd Bergmann 2019-06-17 14:39:29 +02:00 committed by Miklos Szeredi
parent 9179c21dc6
commit 1dac6f5b0e

View File

@ -995,8 +995,8 @@ static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
int err; int err;
trap = ovl_get_trap_inode(sb, dir); trap = ovl_get_trap_inode(sb, dir);
err = PTR_ERR(trap); err = PTR_ERR_OR_ZERO(trap);
if (IS_ERR(trap)) { if (err) {
if (err == -ELOOP) if (err == -ELOOP)
pr_err("overlayfs: conflicting %s path\n", name); pr_err("overlayfs: conflicting %s path\n", name);
return err; return err;