diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-20 00:44:13 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-20 00:44:13 +0000 |
commit | 89c6fc4bee45c341529e586ec35efae29be510a8 (patch) | |
tree | 40fc8385ae9f175f919002b0011b4096b61ece55 | |
parent | 986113a7a343c998360528213a22b25c19b4de58 (diff) | |
download | FreeBSD-src-89c6fc4bee45c341529e586ec35efae29be510a8.zip FreeBSD-src-89c6fc4bee45c341529e586ec35efae29be510a8.tar.gz |
MFC r297618:
fsck_msdosfs(8): Optimimize memsets
Obtained from: NetBSD (bin/50908)
-rw-r--r-- | sbin/fsck_msdosfs/dir.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sbin/fsck_msdosfs/dir.c b/sbin/fsck_msdosfs/dir.c index 65298d8..8e7fe4d 100644 --- a/sbin/fsck_msdosfs/dir.c +++ b/sbin/fsck_msdosfs/dir.c @@ -925,6 +925,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")) @@ -976,14 +977,15 @@ reconnect(int dosfs, struct bootblock *boot, struct fatEntry *fat, cl_t head) 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) { |