Date: Wed, 20 Apr 2016 00:44:13 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r298313 - stable/10/sbin/fsck_msdosfs Message-ID: <201604200044.u3K0iDs3015470@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Wed Apr 20 00:44:13 2016 New Revision: 298313 URL: https://svnweb.freebsd.org/changeset/base/298313 Log: MFC r297618: fsck_msdosfs(8): Optimimize memsets Obtained from: NetBSD (bin/50908) Modified: stable/10/sbin/fsck_msdosfs/dir.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_msdosfs/dir.c ============================================================================== --- stable/10/sbin/fsck_msdosfs/dir.c Wed Apr 20 00:19:04 2016 (r298312) +++ stable/10/sbin/fsck_msdosfs/dir.c Wed Apr 20 00:44:13 2016 (r298313) @@ -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 *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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604200044.u3K0iDs3015470>