summaryrefslogtreecommitdiffstats
path: root/src/shared/sleep-config.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-25 17:02:58 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-25 17:03:02 +0200
commite97c3691530218c031ef0ab9cb33ca5559270aab (patch)
tree52dd542beea2fd73d9caa54640b3c88106007e22 /src/shared/sleep-config.c
parentfileio: introduce read_full_virtual_file() for reading virtual files in sysfs... (diff)
downloadsystemd-e97c3691530218c031ef0ab9cb33ca5559270aab.tar.xz
systemd-e97c3691530218c031ef0ab9cb33ca5559270aab.zip
shared/sleep-config: fix error handling for open
CID#1406472.
Diffstat (limited to 'src/shared/sleep-config.c')
-rw-r--r--src/shared/sleep-config.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index b5bc6595bd..3ead397979 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);