diff options
author | obrien <obrien@FreeBSD.org> | 2008-09-23 14:45:10 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-09-23 14:45:10 +0000 |
commit | d31fa364752ed3b16d83a9cfa2866990824b3eb5 (patch) | |
tree | 4bf6265433e1ef6e4e0356df3e2303dc0c576080 /sys/fs | |
parent | 219d6d162647c587a33965a8d84283e18c02887a (diff) | |
download | FreeBSD-src-d31fa364752ed3b16d83a9cfa2866990824b3eb5.zip FreeBSD-src-d31fa364752ed3b16d83a9cfa2866990824b3eb5.tar.gz |
The kernel implemented 'memcmp' is an alias for 'bcmp'. However, memcmp
and bcmp are not the same thing. 'man bcmp' states that the return is
"non-zero" if the two byte strings are not identical. Where as,
'man memcmp' states that the return is the "difference between the
first two differing bytes (treated as unsigned char values" if the
two byte strings are not identical.
So provide a proper memcmp(9), but it is a C implementation not a tuned
assembly implementation. Therefore bcmp(9) should be preferred over memcmp(9).
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/tmpfs/tmpfs.h | 2 | ||||
-rw-r--r-- | sys/fs/tmpfs/tmpfs_subr.c | 2 | ||||
-rw-r--r-- | sys/fs/tmpfs/tmpfs_vnops.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index b656439..5b3be11 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -445,7 +445,7 @@ int tmpfs_truncate(struct vnode *, off_t); */ #define TMPFS_DIRENT_MATCHES(de, name, len) \ (de->td_namelen == (uint16_t)len && \ - memcmp((de)->td_name, (name), (de)->td_namelen) == 0) + bcmp((de)->td_name, (name), (de)->td_namelen) == 0) /* --------------------------------------------------------------------- */ diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index f5eea18..fad3196 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -585,7 +585,7 @@ tmpfs_dir_lookup(struct tmpfs_node *node, struct componentname *cnp) TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { MPASS(cnp->cn_namelen < 0xffff); if (de->td_namelen == (uint16_t)cnp->cn_namelen && - memcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { + bcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { found = 1; break; } diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 8365b97..54795c1 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -969,7 +969,7 @@ tmpfs_rename(struct vop_rename_args *v) /* Ensure that we have enough memory to hold the new name, if it * has to be changed. */ if (fcnp->cn_namelen != tcnp->cn_namelen || - memcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) { + bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) { newname = malloc(tcnp->cn_namelen, M_TMPFSNAME, M_WAITOK); } else newname = NULL; |