From dac7ff15b7d32deeeef3d9665744fc5774c21d70 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 12 Apr 2006 17:55:51 +0000 Subject: - patch from Denis Vlasenko to add and use bb_xsocket() and to use bb_xopen some more while at it. Also use shorter boilerplate while at it. --- util-linux/mkswap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'util-linux/mkswap.c') diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index ce123e502..32021fe08 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -258,8 +258,7 @@ static inline long get_size(const char *file) int fd; long size; - if ((fd = open(file, O_RDONLY)) < 0) /* TODO: bb_xopen3 */ - bb_perror_msg_and_die("%s", file); + fd = bb_xopen(file, O_RDONLY); if (ioctl(fd, BLKGETSIZE, &size) >= 0) { size /= pagesize / 512; } else { @@ -342,8 +341,8 @@ int mkswap_main(int argc, char **argv) PAGES * goodpages); } - DEV = open(device_name, O_RDWR); - if (DEV < 0 || fstat(DEV, &statbuf) < 0) + DEV = bb_xopen(device_name, O_RDWR); + if (fstat(DEV, &statbuf) < 0) bb_perror_msg_and_die("%s", device_name); if (!S_ISBLK(statbuf.st_mode)) check = 0; -- cgit v1.2.3