Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Mar 2012 18:34:14 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232738 - head/usr.sbin/diskinfo
Message-ID:  <201203091834.q29IYEoc019711@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Fri Mar  9 18:34:14 2012
New Revision: 232738
URL: http://svn.freebsd.org/changeset/base/232738

Log:
  Improve error reporting in diskinfo(8) by not displaying errno when
  it doesn't make sense.

Modified:
  head/usr.sbin/diskinfo/diskinfo.c

Modified: head/usr.sbin/diskinfo/diskinfo.c
==============================================================================
--- head/usr.sbin/diskinfo/diskinfo.c	Fri Mar  9 18:26:35 2012	(r232737)
+++ head/usr.sbin/diskinfo/diskinfo.c	Fri Mar  9 18:34:14 2012	(r232738)
@@ -99,13 +99,13 @@ main(int argc, char **argv)
 		}
 		error = ioctl(fd, DIOCGMEDIASIZE, &mediasize);
 		if (error) {
-			warn("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
+			warnx("%s: ioctl(DIOCGMEDIASIZE) failed, probably not a disk.", argv[i]);
 			exitval = 1;
 			goto out;
 		}
 		error = ioctl(fd, DIOCGSECTORSIZE, &sectorsize);
 		if (error) {
-			warn("%s: DIOCGSECTORSIZE failed, probably not a disk.", argv[i]);
+			warnx("%s: ioctl(DIOCGSECTORSIZE) failed, probably not a disk.", argv[i]);
 			exitval = 1;
 			goto out;
 		}
@@ -178,8 +178,10 @@ rdsect(int fd, off_t blockno, u_int sect
 
 	lseek(fd, (off_t)blockno * sectorsize, SEEK_SET);
 	error = read(fd, sector, sectorsize);
+	if (error == -1)
+		err(1, "read");
 	if (error != (int)sectorsize)
-		err(1, "read error or disk too small for test.");
+		errx(1, "disk too small for test.");
 }
 
 static void
@@ -188,8 +190,10 @@ rdmega(int fd)
 	int error;
 
 	error = read(fd, mega, sizeof(mega));
+	if (error == -1)
+		err(1, "read");
 	if (error != sizeof(mega))
-		err(1, "read error or disk too small for test.");
+		errx(1, "disk too small for test.");
 }
 
 static struct timeval tv1, tv2;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203091834.q29IYEoc019711>