summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/dmesg.c15
-rw-r--r--util-linux/fbset.c10
-rw-r--r--util-linux/fdflush.c18
-rw-r--r--util-linux/mkfs_minix.c7
-rw-r--r--util-linux/mkswap.c13
-rw-r--r--util-linux/mount.c2
-rw-r--r--util-linux/swaponoff.c12
-rw-r--r--util-linux/umount.c5
8 files changed, 25 insertions, 57 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 1d33b76..c220d90 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -69,20 +69,16 @@ int dmesg_main(int argc, char **argv)
}
if (cmd == 8) {
- n = klogctl(cmd, NULL, level);
- if (n < 0) {
- goto klogctl_error;
- }
+ if (klogctl(cmd, NULL, level) < 0)
+ perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
if (bufsize < 4096)
bufsize = 4096;
buf = (char *) xmalloc(bufsize);
- n = klogctl(cmd, buf, bufsize);
- if (n < 0) {
- goto klogctl_error;
- }
+ if ((n = klogctl(cmd, buf, bufsize)) < 0)
+ perror_msg_and_die("klogctl");
lastc = '\n';
for (i = 0; i < n; i++) {
@@ -102,7 +98,4 @@ int dmesg_main(int argc, char **argv)
end:
usage(dmesg_usage);
return EXIT_FAILURE;
- klogctl_error:
- perror("klogctl");
- return EXIT_FAILURE;
}
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 86f7733..40a907b 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -33,8 +33,6 @@
#include <ctype.h>
#include <sys/ioctl.h>
-#define PERROR(ctx) do { perror(ctx); exit(1); } while(0)
-
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
@@ -198,7 +196,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
char *p = buf;
if ((f = fopen(fn, "r")) == NULL)
- PERROR("readmode(fopen)");
+ perror_msg_and_die("readmode(fopen)");
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
@@ -428,9 +426,9 @@ extern int fbset_main(int argc, char **argv)
}
if ((fh = open(fbdev, O_RDONLY)) < 0)
- PERROR("fbset(open)");
+ perror_msg_and_die("fbset(open)");
if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
error_msg("Unknown video mode `%s'\n", mode);
@@ -441,7 +439,7 @@ extern int fbset_main(int argc, char **argv)
setmode(&var, &varset);
if (g_options & OPT_CHANGE)
if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
showmode(&var);
/* Don't close the file, as exiting will take care of that */
/* close(fh); */
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index 380015d..5eb93dd 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -31,26 +31,16 @@
extern int fdflush_main(int argc, char **argv)
{
- int value;
int fd;
if (argc <= 1 || **(++argv) == '-')
usage(fdflush_usage);
- fd = open(*argv, 0);
- if (fd < 0) {
- perror(*argv);
- return EXIT_FAILURE;
- }
+ if ((fd = open(*argv, 0)) < 0)
+ perror_msg_and_die("%s", *argv);
- value = ioctl(fd, FDFLUSH, 0);
- /* Don't bother closing. Exit does
- * that, so we can save a few bytes */
- /* close(fd); */
+ if (ioctl(fd, FDFLUSH, 0))
+ perror_msg_and_die("%s", *argv);
- if (value) {
- perror(*argv);
- return EXIT_FAILURE;
- }
return EXIT_SUCCESS;
}
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 95815fd..e1ede6c 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -329,11 +329,8 @@ static int get_size(const char *file)
int fd;
long size;
- fd = open(file, O_RDWR);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDWR)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
close(fd);
return (size * 512);
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 60ae286..e7fab4e 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -260,11 +260,8 @@ static long get_size(const char *file)
int fd;
long size;
- fd = open(file, O_RDONLY);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDONLY)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
int sectors_per_page = pagesize / 512;
@@ -367,10 +364,8 @@ int mkswap_main(int argc, char **argv)
}
DEV = open(device_name, O_RDWR);
- if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
- perror(device_name);
- return EXIT_FAILURE;
- }
+ if (DEV < 0 || fstat(DEV, &statbuf) < 0)
+ perror_msg_and_die("%s", device_name);
if (!S_ISBLK(statbuf.st_mode))
check = 0;
else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 8240b99..97b60ab 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -383,7 +383,7 @@ extern int mount_main(int argc, char **argv)
}
endmntent(mountTable);
} else {
- perror(mtab_file);
+ perror_msg_and_die("%s", mtab_file);
}
return EXIT_SUCCESS;
}
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index e40d169..85f3389 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -48,10 +48,8 @@ static void swap_enable_disable(char *device)
else
status = swapoff(device);
- if (status != 0) {
- perror(applet_name);
- exit(EXIT_FAILURE);
- }
+ if (status != 0)
+ perror_msg_and_die(applet_name);
}
static void do_em_all()
@@ -59,10 +57,8 @@ static void do_em_all()
struct mntent *m;
FILE *f = setmntent("/etc/fstab", "r");
- if (f == NULL) {
- perror("/etc/fstab");
- exit(FALSE);
- }
+ if (f == NULL)
+ perror_msg_and_die("/etc/fstab");
while ((m = getmntent(f)) != NULL) {
if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) {
swap_enable_disable(m->mnt_fsname);
diff --git a/util-linux/umount.c b/util-linux/umount.c
index e76e052..0867118 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -216,7 +216,7 @@ static int umount_all(int useMtab)
if (status != 0) {
/* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) {
- perror(mountpt);
+ perror_msg("%s", mountpt);
continue;
}
status = do_umount(mountpt, useMtab);
@@ -280,7 +280,6 @@ extern int umount_main(int argc, char **argv)
}
if (do_umount(*argv, useMtab) == TRUE)
return EXIT_SUCCESS;
- perror("umount");
- return EXIT_FAILURE;
+ perror_msg_and_die("%s", *argv);
}