[PATCH 2/4] isosize: simplify some error messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



perror() and fprintf() are replaced with err() calls

Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
---
 disk-utils/isosize.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c
index 5f0358e..36c9387 100644
--- a/disk-utils/isosize.c
+++ b/disk-utils/isosize.c
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
+#include <err.h>
 
 #include "nls.h"
 
@@ -124,24 +125,14 @@ isosize(char *filenamep) {
 	int fd, nsecs, ssize;
 	struct iso_primary_descriptor ipd;
 
-	if ((fd = open(filenamep, O_RDONLY)) < 0) {
-		perror(filenamep);
-		fprintf(stderr, _("%s: failed to open: %s\n"),
-			progname, filenamep);
-		exit(1);
-	}
-	if (lseek(fd, 16 << 11, 0) == (off_t)-1) {
-		perror("lseek");
-		fprintf(stderr, _("%s: seek error on %s\n"),
-			progname, filenamep);
-		exit(1);
-	}
-	if (read(fd, &ipd, sizeof(ipd)) < 0) {
-		perror("read");
-		fprintf(stderr, _("%s: read error on %s\n"),
-			progname, filenamep);
-		exit(1);
-	}
+	if ((fd = open(filenamep, O_RDONLY)) < 0)
+		err(EXIT_FAILURE, _("failed to open %s"), filenamep);
+
+	if (lseek(fd, 16 << 11, 0) == (off_t)-1)
+		err(EXIT_FAILURE, _("seek error on %s"), filenamep);
+
+	if (read(fd, &ipd, sizeof(ipd)) < 0)
+		err(EXIT_FAILURE, _("read error on %s"), filenamep);
 
 	nsecs = isonum_733(ipd.volume_space_size);
 	ssize = isonum_723(ipd.logical_block_size); /* nowadays always 2048 */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux