Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/newfs PR/50910: David Binderman: Optimize memset.



details:   https://anonhg.NetBSD.org/src/rev/78e997d823fd
branches:  trunk
changeset: 814112:78e997d823fd
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 07 15:55:06 2016 +0000

description:
PR/50910: David Binderman: Optimize memset.

diffstat:

 sbin/newfs/mkfs.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r ed0cdb816f7f -r 78e997d823fd sbin/newfs/mkfs.c
--- a/sbin/newfs/mkfs.c Mon Mar 07 15:09:55 2016 +0000
+++ b/sbin/newfs/mkfs.c Mon Mar 07 15:55:06 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $      */
+/*     $NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c     8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -735,8 +735,10 @@
         * Write out the super-block and zeros until the first cg info
         */
        i = cgsblock(&sblock, 0) * sblock.fs_fsize - sblock.fs_sblockloc;
-       memset(iobuf, 0, i);
-       memcpy(iobuf, &sblock, sizeof sblock);
+       if ((size_t)i < sizeof(sblock))
+               errx(1, "No space for superblock");
+       memcpy(iobuf, &sblock, sizeof(sblock));
+       memset(iobuf + sizeof(sblock), 0, i - sizeof(sblock));
        if (needswap)
                ffs_sb_swap(&sblock, (struct fs *)iobuf);
        if ((sblock.fs_old_flags & FS_FLAGS_UPDATED) == 0)



Home | Main Index | Thread Index | Old Index