]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix variable shadowing
authorSami Kerola <kerolasa@iki.fi>
Sat, 27 May 2017 09:03:55 +0000 (10:03 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 29 May 2017 10:18:08 +0000 (12:18 +0200)
libfdisk/src/context.c: In function 'fdisk_assign_device':
libfdisk/src/context.c:549:7: warning: declaration of 'rc' shadows a previous local [-Wshadow]
libfdisk/src/context.c:542:10: note: shadowed declaration is here

[kzak@redhat.com: - add rc to debug message]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index 52fd57987a6ed5df513638fe259120600b1a5399..951310ffae2a233b716cc5b57cd92e48fa98d9f4 100644 (file)
@@ -539,7 +539,7 @@ static void reset_context(struct fdisk_context *cxt)
 int fdisk_assign_device(struct fdisk_context *cxt,
                        const char *fname, int readonly)
 {
-       int fd, rc = 0;
+       int fd;
 
        DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname));
        assert(cxt);
@@ -600,11 +600,13 @@ int fdisk_assign_device(struct fdisk_context *cxt,
                              fname, readonly ? "READ-ONLY" : "READ-WRITE"));
        return 0;
 fail:
-       rc = -errno;
-       if (fd >= 0)
-               close(fd);
-       DBG(CXT, ul_debugobj(cxt, "failed to assign device"));
-       return rc;
+       {
+               int rc = -errno;
+               if (fd >= 0)
+                       close(fd);
+               DBG(CXT, ul_debugobj(cxt, "failed to assign device [rc=%d]", rc));
+               return rc;
+       }
 }
 
 /**