From a079039934311f64a48e1010a97492a22126042e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 Feb 2021 03:08:26 -0600 Subject: Have xclose() perform the fd != -1 test. --- toys/other/hwclock.c | 2 +- toys/other/losetup.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'toys/other') diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c index a6db923a..541c70a3 100644 --- a/toys/other/hwclock.c +++ b/toys/other/hwclock.c @@ -84,5 +84,5 @@ void hwclock_main() if (settimeofday(&timeval, &tzone)) perror_exit("settimeofday failed"); } - if (fd != -1) close(fd); + xclose(fd); } diff --git a/toys/other/losetup.c b/toys/other/losetup.c index 27d25a18..7b8aed4f 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -52,7 +52,7 @@ GLOBALS( static int loopback_setup(char *device, char *file) { struct loop_info64 *loop = (void *)(toybuf+32); - int lfd = -1, ffd = ffd; + int lfd = -1, ffd = -1; int racy = !device; // Open file (ffd) and loop device (lfd) @@ -129,8 +129,8 @@ static int loopback_setup(char *device, char *file) } done: - if (file) close(ffd); - if (lfd != -1) close(lfd); + xclose(ffd); + xclose(lfd); return 0; } -- cgit v1.2.3