]> err.no Git - util-linux/commitdiff
fdisk: more meaningful error messages (use err.h)
authorFrancesco Cosoleto <cosoleto@gmail.com>
Sun, 23 Jan 2011 21:58:14 +0000 (22:58 +0100)
committerKarel Zak <kzak@redhat.com>
Sun, 23 Jan 2011 22:33:45 +0000 (23:33 +0100)
[kzak@redhat.com: - minor changes in error messages]

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisk.c

index d5216b2624ae8931c8cf8b6d8240ea83b230703c..b6b81e493f752bcd0aa5ba368db0193ff93c23ad 100644 (file)
@@ -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