From: Francesco Cosoleto Date: Sun, 23 Jan 2011 21:58:14 +0000 (+0100) Subject: fdisk: more meaningful error messages (use err.h) X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c845f12cacb870f22c91eef799debc33f7e802b8;p=util-linux fdisk: more meaningful error messages (use err.h) [kzak@redhat.com: - minor changes in error messages] Signed-off-by: Francesco Cosoleto Signed-off-by: Karel Zak --- 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