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));
 }
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to