Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_msdos PR/50908: David Binderman: Optimize memset's
details: https://anonhg.NetBSD.org/src/rev/379fa02596b1
branches: trunk
changeset: 343968:379fa02596b1
user: christos <christos%NetBSD.org@localhost>
date: Mon Mar 07 14:47:25 2016 +0000
description:
PR/50908: David Binderman: Optimize memset's
diffstat:
sbin/fsck_msdos/dir.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diffs (46 lines):
diff -r 5b43606e4e7b -r 379fa02596b1 sbin/fsck_msdos/dir.c
--- a/sbin/fsck_msdos/dir.c Mon Mar 07 14:35:39 2016 +0000
+++ b/sbin/fsck_msdos/dir.c Mon Mar 07 14:47:25 2016 +0000
@@ -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 @@
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 @@
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) {
Home |
Main Index |
Thread Index |
Old Index