summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-03-26 07:17:24 +0000
committerpjd <pjd@FreeBSD.org>2011-03-26 07:17:24 +0000
commit0d6974a72124b781ee06810058cc18e1fdc54767 (patch)
treeeb01cbec21a06d647e88a6b5797d2b26e53ac71b /lib
parent5cdf4e6f59745010af06545c1942d47da5dd3764 (diff)
downloadFreeBSD-src-0d6974a72124b781ee06810058cc18e1fdc54767.zip
FreeBSD-src-0d6974a72124b781ee06810058cc18e1fdc54767.tar.gz
Don't calculate len too early.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/directory.32
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index e6d8798..992d2fc 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -207,10 +207,10 @@ see
.Pp
Sample code which searches a directory for entry ``name'' is:
.Bd -literal -offset indent
-len = strlen(name);
dirp = opendir(".");
if (dirp == NULL)
return (ERROR);
+len = strlen(name);
while ((dp = readdir(dirp)) != NULL) {
if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) {
(void)closedir(dirp);
OpenPOWER on IntegriCloud