From 3d5c8ba1c9f0e2eada689204bc8e2d429611b0c9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Nov 2014 20:26:27 +0000 Subject: mkswap: use err() rather than perror() && exit() The messsages in err() are verified from po/util-linux.pot to be already part of translations. Signed-off-by: Sami Kerola --- disk-utils/mkswap.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'disk-utils/mkswap.c') diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index b2713ab99..14adf0fed 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -209,10 +209,8 @@ get_size(const char *file) unsigned long long size; fd = open(file, O_RDONLY); - if (fd < 0) { - perror(file); - exit(EXIT_FAILURE); - } + if (fd < 0) + err(EXIT_FAILURE, _("cannot open %s"), file); if (blkdev_get_size(fd, &size) == 0) size /= pagesize; @@ -434,19 +432,14 @@ main(int argc, char **argv) { "%s is mounted; will not make swapspace"), device_name); - if (stat(device_name, &statbuf) < 0) { - perror(device_name); - exit(EXIT_FAILURE); - } + if (stat(device_name, &statbuf) < 0) + err(EXIT_FAILURE, _("stat failed %s"), device_name); if (S_ISBLK(statbuf.st_mode)) DEV = open(device_name, O_RDWR | O_EXCL); else DEV = open(device_name, O_RDWR); - - if (DEV < 0) { - perror(device_name); - exit(EXIT_FAILURE); - } + if (DEV < 0) + err(EXIT_FAILURE, _("cannot open %s"), device_name); if (!S_ISBLK(statbuf.st_mode)) check=0; -- cgit v1.2.3-55-g7522