From e97c3691530218c031ef0ab9cb33ca5559270aab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 25 Oct 2019 17:02:58 +0200 Subject: [PATCH] shared/sleep-config: fix error handling for open CID#1406472. --- src/shared/sleep-config.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index b5bc659..3ead397 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -226,11 +226,10 @@ static int calculate_swap_file_offset(const SwapEntry *swap, uint64_t *ret_offse assert(streq(swap->type, "file")); fd = open(swap->device, O_RDONLY|O_CLOEXEC|O_NOCTTY); - if (!fd) + if (fd < 0) return log_error_errno(errno, "Failed to open %s: %m", swap->device); - r = fstat(fd, &sb); - if (r < 0) + if (fstat(fd, &sb) < 0) return log_error_errno(errno, "Failed to stat %s: %m", swap->device); btrfs = btrfs_is_filesystem(fd); -- 2.7.4