From owner-svn-src-stable@FreeBSD.ORG Wed Aug 18 14:41:35 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1133C1065693; Wed, 18 Aug 2010 14:41:35 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA8728FC21; Wed, 18 Aug 2010 14:41:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7IEfYIb071600; Wed, 18 Aug 2010 14:41:34 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7IEfY4e071598; Wed, 18 Aug 2010 14:41:34 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201008181441.o7IEfY4e071598@svn.freebsd.org> From: Jaakko Heinonen Date: Wed, 18 Aug 2010 14:41:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211454 - stable/7/sbin/bsdlabel X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2010 14:41:35 -0000 Author: jh Date: Wed Aug 18 14:41:34 2010 New Revision: 211454 URL: http://svn.freebsd.org/changeset/base/211454 Log: MFC r209614: - Don't assign the return value from read(2) to a variable of type int. - Use errx(3) instead of err(3) to print the error message on short reads in readlabel(). errno won't be set on short reads which can easily occur here due to the fixed size read request. PR: 144307 Modified: stable/7/sbin/bsdlabel/bsdlabel.c Directory Properties: stable/7/sbin/bsdlabel/ (props changed) Modified: stable/7/sbin/bsdlabel/bsdlabel.c ============================================================================== --- stable/7/sbin/bsdlabel/bsdlabel.c Wed Aug 18 12:52:21 2010 (r211453) +++ stable/7/sbin/bsdlabel/bsdlabel.c Wed Aug 18 14:41:34 2010 (r211454) @@ -334,7 +334,7 @@ makelabel(const char *type, struct diskl static void readboot(void) { - int fd, i; + int fd; struct stat st; uint64_t *p; @@ -345,8 +345,7 @@ readboot(void) err(1, "cannot open %s", xxboot); fstat(fd, &st); if (alphacksum && st.st_size <= BBSIZE - 512) { - i = read(fd, bootarea + 512, st.st_size); - if (i != st.st_size) + if (read(fd, bootarea + 512, st.st_size) != st.st_size) err(1, "read error %s", xxboot); /* @@ -359,8 +358,7 @@ readboot(void) p[62] = 0; return; } else if ((!alphacksum) && st.st_size <= BBSIZE) { - i = read(fd, bootarea, st.st_size); - if (i != st.st_size) + if (read(fd, bootarea, st.st_size) != st.st_size) err(1, "read error %s", xxboot); return; } @@ -466,6 +464,7 @@ get_file_parms(int f) static int readlabel(int flag) { + ssize_t nbytes; int f, i; int error; struct gctl_req *grq; @@ -484,8 +483,11 @@ readlabel(int flag) errx(1, "disks with more than 2^32-1 sectors are not supported"); (void)lseek(f, (off_t)0, SEEK_SET); - if (read(f, bootarea, BBSIZE) != BBSIZE) + nbytes = read(f, bootarea, BBSIZE); + if (nbytes == -1) err(4, "%s read", specname); + if (nbytes != BBSIZE) + errx(4, "couldn't read %d bytes from %s", BBSIZE, specname); close (f); error = bsd_disklabel_le_dec( bootarea + (labeloffset + labelsoffset * secsize),