From owner-svn-src-all@FreeBSD.ORG Sat Nov 29 09:27:19 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0938699A; Sat, 29 Nov 2014 09:27:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E986FED3; Sat, 29 Nov 2014 09:27:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAT9RI1g077605; Sat, 29 Nov 2014 09:27:18 GMT (envelope-from nyan@FreeBSD.org) Received: (from nyan@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAT9RII2077604; Sat, 29 Nov 2014 09:27:18 GMT (envelope-from nyan@FreeBSD.org) Message-Id: <201411290927.sAT9RII2077604@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nyan set sender to nyan@FreeBSD.org using -f From: Takahashi Yoshihiro Date: Sat, 29 Nov 2014 09:27:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275239 - head/sys/boot/pc98/boot2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Nov 2014 09:27:19 -0000 Author: nyan Date: Sat Nov 29 09:27:18 2014 New Revision: 275239 URL: https://svnweb.freebsd.org/changeset/base/275239 Log: MFi386: r275237 (by rdivacky) Shrink boot2 a bit more by factoring out common pattern of printf();return(-1); Modified: head/sys/boot/pc98/boot2/boot2.c Modified: head/sys/boot/pc98/boot2/boot2.c ============================================================================== --- head/sys/boot/pc98/boot2/boot2.c Sat Nov 29 09:09:54 2014 (r275238) +++ head/sys/boot/pc98/boot2/boot2.c Sat Nov 29 09:27:18 2014 (r275239) @@ -639,6 +639,7 @@ dskread(void *buf, unsigned lba, unsigne unsigned i; uint8_t sl; u_char *p; + const char *reason; if (!dsk_meta) { sec = dmadat->secbuf; @@ -660,8 +661,8 @@ dskread(void *buf, unsigned lba, unsigne if (sl != WHOLE_DISK_SLICE) { dp += sl - BASE_SLICE; if (dp->dp_mid != DOSMID_386BSD) { - printf("Invalid %s\n", "slice"); - return -1; + reason = "slice"; + goto error; } dsk.start = dp->dp_scyl * dsk.head * dsk.sec + dp->dp_shd * dsk.sec + dp->dp_ssect; @@ -671,14 +672,14 @@ dskread(void *buf, unsigned lba, unsigne d = (void *)(sec + LABELOFFSET); if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) { if (dsk.part != RAW_PART) { - printf("Invalid %s\n", "label"); - return -1; + reason = "label"; + goto error; } } else { if (dsk.part >= d->d_npartitions || !d->d_partitions[dsk.part].p_size) { - printf("Invalid %s\n", "partition"); - return -1; + reason = "partition"; + goto error; } dsk.start += d->d_partitions[dsk.part].p_offset; dsk.start -= d->d_partitions[RAW_PART].p_offset; @@ -690,6 +691,9 @@ dskread(void *buf, unsigned lba, unsigne return i; } return 0; +error: + printf("Invalid %s\n", reason); + return -1; } static void