Module Name: src
Committed By: christos
Date: Mon Mar 7 14:47:25 UTC 2016
Modified Files:
src/sbin/fsck_msdos: dir.c
Log Message:
PR/50908: David Binderman: Optimize memset's
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_msdos/dir.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/fsck_msdos/dir.c
diff -u src/sbin/fsck_msdos/dir.c:1.27 src/sbin/fsck_msdos/dir.c:1.28
--- src/sbin/fsck_msdos/dir.c:1.27 Fri Jan 2 01:21:28 2015
+++ src/sbin/fsck_msdos/dir.c Mon Mar 7 09:47:25 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.27 2015/01/02 06:21:28 mlelstv Exp $ */
+/* $NetBSD: dir.c,v 1.28 2016/03/07 14:47:25 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: dir.c,v 1.27 2015/01/02 06:21:28 mlelstv Exp $");
+__RCSID("$NetBSD: dir.c,v 1.28 2016/03/07 14:47:25 christos Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -929,6 +929,7 @@ int
reconnect(int dosfs, struct bootblock *boot, struct fatEntry *fat, cl_t head)
{
struct dosDirEntry d;
+ int len;
u_char *p;
if (!ask(1, "Reconnect"))
@@ -980,14 +981,15 @@ reconnect(int dosfs, struct bootblock *b
boot->NumFiles++;
/* Ensure uniqueness of entry here! XXX */
memset(&d, 0, sizeof d);
- (void)snprintf(d.name, sizeof(d.name), "%u", head);
+ /* worst case -1 = 4294967295, 10 digits */
+ len = snprintf(d.name, sizeof(d.name), "%u", head);
d.flags = 0;
d.head = head;
d.size = fat[head].length * boot->ClusterSize;
- memset(p, 0, 32);
- memset(p, ' ', 11);
- memcpy(p, d.name, strlen(d.name));
+ memcpy(p, d.name, len);
+ memset(p + len, ' ', 11 - len);
+ memset(p + 11, 0, 32 - 11);
p[26] = (u_char)d.head;
p[27] = (u_char)(d.head >> 8);
if (boot->ClustMask == CLUST32_MASK) {