Date: Sat, 26 Mar 2011 07:17:24 +0000 (UTC) From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r220024 - head/lib/libc/gen Message-ID: <201103260717.p2Q7HOA4006941@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pjd Date: Sat Mar 26 07:17:24 2011 New Revision: 220024 URL: http://svn.freebsd.org/changeset/base/220024 Log: Don't calculate len too early. Modified: head/lib/libc/gen/directory.3 Modified: head/lib/libc/gen/directory.3 ============================================================================== --- head/lib/libc/gen/directory.3 Sat Mar 26 07:15:57 2011 (r220023) +++ head/lib/libc/gen/directory.3 Sat Mar 26 07:17:24 2011 (r220024) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103260717.p2Q7HOA4006941>