]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't pass -1 to close() [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 10:45:30 +0000 (12:45 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 17 May 2017 10:45:30 +0000 (12:45 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/utils.c

index 3b27135cdb692728441f86b5dab348654b0d02ec..a5617e6c02d1617788818f9e2a089030bd22ddb3 100644 (file)
@@ -647,7 +647,7 @@ done:
 
 static int try_write(const char *filename)
 {
-       int fd, ret = 0;
+       int fd, rc = 0;
 
        if (!filename)
                return -EINVAL;
@@ -655,9 +655,10 @@ static int try_write(const char *filename)
        fd = open(filename, O_RDWR|O_CREAT|O_CLOEXEC,
                            S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
        if (fd < 0)
-               ret = -errno;
-       close(fd);
-       return ret;
+               rc = -errno;
+       else
+               close(fd);
+       return rc;
 }
 
 /**