summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Cosoleto <cosoleto@gmail.com>2011-01-23 22:58:14 +0100
committerKarel Zak <kzak@redhat.com>2011-01-23 23:33:45 +0100
commitc845f12cacb870f22c91eef799debc33f7e802b8 (patch)
treee79ffd3ea7709aab8797bd4564b4ddcf074c850d
parent52b38677e2963e92479d2ac88442c8acb01cb589 (diff)
downloadutil-linux-old-c845f12cacb870f22c91eef799debc33f7e802b8.tar.gz
fdisk: more meaningful error messages (use err.h)
[kzak@redhat.com: - minor changes in error messages] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisk/fdisk.c35
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