diff options
-rw-r--r-- | fdisk/fdisk.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index d5216b26..b6b81e49 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -265,9 +265,6 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) } void fatal(enum failure why) { - char error[LINE_LENGTH], - *message = error; - int rc = EXIT_FAILURE; if (listing) { close(fd); @@ -276,33 +273,23 @@ void fatal(enum failure why) { switch (why) { case unable_to_open: - snprintf(error, sizeof(error), - _("Unable to open %s\n"), disk_device); - break; + err(EXIT_FAILURE, _("unable to open %s"), disk_device); + case unable_to_read: - snprintf(error, sizeof(error), - _("Unable to read %s\n"), disk_device); - break; + err(EXIT_FAILURE, _("unable to read %s"), disk_device); + case unable_to_seek: - snprintf(error, sizeof(error), - _("Unable to seek on %s\n"),disk_device); - break; + err(EXIT_FAILURE, _("unable to seek on %s"), disk_device); + case unable_to_write: - snprintf(error, sizeof(error), - _("Unable to write %s\n"), disk_device); - break; + err(EXIT_FAILURE, _("unable to write %s"), disk_device); + case ioctl_error: - snprintf(error, sizeof(error), - _("BLKGETSIZE ioctl failed on %s\n"), - disk_device); - break; + err(EXIT_FAILURE, _("BLKGETSIZE ioctl failed on %s"), disk_device); + default: - message = _("Fatal error\n"); + err(EXIT_FAILURE, _("fatal error")); } - - fputc('\n', stderr); - fputs(message, stderr); - exit(rc); } static void |