svn commit: r355999 - stable/11/sbin/newfs_msdos

Xin LI delphij at FreeBSD.org
Sun Dec 22 05:43:14 UTC 2019


Author: delphij
Date: Sun Dec 22 05:43:13 2019
New Revision: 355999
URL: https://svnweb.freebsd.org/changeset/base/355999

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/11/sbin/newfs_msdos/mkfs_msdos.c
  stable/11/sbin/newfs_msdos/newfs_msdos.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c
==============================================================================
--- stable/11/sbin/newfs_msdos/mkfs_msdos.c	Sun Dec 22 05:39:26 2019	(r355998)
+++ stable/11/sbin/newfs_msdos/mkfs_msdos.c	Sun Dec 22 05:43:13 2019	(r355999)
@@ -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/11/sbin/newfs_msdos/newfs_msdos.c
==============================================================================
--- stable/11/sbin/newfs_msdos/newfs_msdos.c	Sun Dec 22 05:39:26 2019	(r355998)
+++ stable/11/sbin/newfs_msdos/newfs_msdos.c	Sun Dec 22 05:43:13 2019	(r355999)
@@ -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));
 }
 
 /*


More information about the svn-src-all mailing list