]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: don't use errno after close()
authorKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 10:43:48 +0000 (12:43 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 10:43:48 +0000 (12:43 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index 02b035c928c379b66851fad10c70225b018d3b3d..4fe24d0114f52b163d398491adc7c1ad33c353b9 100644 (file)
@@ -537,7 +537,7 @@ static void reset_context(struct fdisk_context *cxt)
 int fdisk_assign_device(struct fdisk_context *cxt,
                        const char *fname, int readonly)
 {
-       int fd;
+       int fd, rc = 0;
 
        DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname));
        assert(cxt);
@@ -598,10 +598,11 @@ 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 -errno;
+       return rc;
 }
 
 /**