From owner-svn-src-all@freebsd.org Sun Dec 22 05:39:27 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D32A1C8C40; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gWWg0y1Wz43d7; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1BC8822DCE; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBM5dQAn040016; Sun, 22 Dec 2019 05:39:26 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBM5dQ5Z040014; Sun, 22 Dec 2019 05:39:26 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201912220539.xBM5dQ5Z040014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 22 Dec 2019 05:39:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355998 - stable/12/sbin/newfs_msdos X-SVN-Group: stable-12 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/12/sbin/newfs_msdos X-SVN-Commit-Revision: 355998 X-SVN-Commit-Repository: base 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.29 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: Sun, 22 Dec 2019 05:39:27 -0000 Author: delphij Date: Sun Dec 22 05:39:26 2019 New Revision: 355998 URL: https://svnweb.freebsd.org/changeset/base/355998 Log: MFC r355318, r355513 r355318: Explicitly exit() instead of return in main(). r355513: Fix a couple of minor issues with newfs_msdos: - Do not unnecessarily strdup(). - Check return value of getdiskinfo(), if it failed, bail out. Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c stable/12/sbin/newfs_msdos/newfs_msdos.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 04:21:16 2019 (r355997) +++ stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 05:39:26 2019 (r355998) @@ -316,7 +316,8 @@ mkfs_msdos(const char *fname, const char *dtype, const bpb.bpbHiddenSecs = o.hidden_sectors; if (!(o.floppy || (o.drive_heads && o.sectors_per_track && o.bytes_per_sector && o.size && o.hidden_sectors_set))) { - getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb); + if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1) + goto done; bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec); if (bpb.bpbSecPerClust == 0) { /* set defaults */ if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ @@ -421,10 +422,7 @@ mkfs_msdos(const char *fname, const char *dtype, const bname = o.bootstrap; if (!strchr(bname, '/')) { snprintf(buf, sizeof(buf), "/boot/%s", bname); - if (!(bname = strdup(buf))) { - warn(NULL); - goto done; - } + bname = buf; } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) { warn("%s", bname); Modified: stable/12/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/12/sbin/newfs_msdos/newfs_msdos.c Sun Dec 22 04:21:16 2019 (r355997) +++ stable/12/sbin/newfs_msdos/newfs_msdos.c Sun Dec 22 05:39:26 2019 (r355998) @@ -185,11 +185,10 @@ main(int argc, char *argv[]) fname = *argv++; if (!o.create_size && !strchr(fname, '/')) { snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); - if (!(fname = strdup(buf))) - err(1, NULL); + fname = buf; } dtype = *argv; - return !!mkfs_msdos(fname, dtype, &o); + exit(!!mkfs_msdos(fname, dtype, &o)); } /*