Author: des
Date: Tue Aug 20 07:19:58 2013
New Revision: 254553
URL: http://svnweb.freebsd.org/changeset/base/254553

Log:
  Fix the zeroing loop.  I must have been drunk when I wrote this...
  
  MFC after:    3 days

Modified:
  head/sbin/fsck_ffs/fsutil.c

Modified: head/sbin/fsck_ffs/fsutil.c
==============================================================================
--- head/sbin/fsck_ffs/fsutil.c Tue Aug 20 07:15:16 2013        (r254552)
+++ head/sbin/fsck_ffs/fsutil.c Tue Aug 20 07:19:58 2013        (r254553)
@@ -629,6 +629,10 @@ blerase(int fd, ufs2_daddr_t blk, long s
        return;
 }
 
+/*
+ * Fill a contiguous region with all-zeroes.  Note ZEROBUFSIZE is by
+ * definition a multiple of dev_bsize.
+ */
 void
 blzero(int fd, ufs2_daddr_t blk, long size)
 {
@@ -637,9 +641,8 @@ blzero(int fd, ufs2_daddr_t blk, long si
 
        if (fd < 0)
                return;
-       len = ZEROBUFSIZE;
        if (zero == NULL) {
-               zero = calloc(len, 1);
+               zero = calloc(ZEROBUFSIZE, 1);
                if (zero == NULL)
                        errx(EEXIT, "cannot allocate buffer pool");
        }
@@ -647,10 +650,7 @@ blzero(int fd, ufs2_daddr_t blk, long si
        if (lseek(fd, offset, 0) < 0)
                rwerror("SEEK BLK", blk);
        while (size > 0) {
-               if (size > len)
-                       size = len;
-               else
-                       len = size;
+               len = size > ZEROBUFSIZE ? ZEROBUFSIZE : size;
                if (write(fd, zero, len) != len)
                        rwerror("WRITE BLK", blk);
                blk += len / dev_bsize;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to