libmount: don't pass -1 to close() [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2017-05-17 12:45:30 +02:00
parent 199f8cd3b5
commit 7a5dbd2258
1 changed files with 5 additions and 4 deletions

View 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;
}
/**