summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorKarel Zak2017-05-17 12:45:30 +0200
committerKarel Zak2017-05-17 12:45:30 +0200
commit7a5dbd22588fcf402ab15f82917891d176dfca74 (patch)
tree0e99e99558f5034bb01c7c7c8d7fa0cf61aa112c /libmount/src/utils.c
parentlibfdisk: don't use errno after close() (diff)
downloadkernel-qcow2-util-linux-7a5dbd22588fcf402ab15f82917891d176dfca74.tar.gz
kernel-qcow2-util-linux-7a5dbd22588fcf402ab15f82917891d176dfca74.tar.xz
kernel-qcow2-util-linux-7a5dbd22588fcf402ab15f82917891d176dfca74.zip
libmount: don't pass -1 to close() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 3b27135cd..a5617e6c0 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -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;
}
/**