From fd344dd6673bf0defd17cf33b4a91ce378f1d1b4 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 18 Sep 2017 15:57:03 +0000 Subject: Document readdir_r() return value and update style of the example code. Adapted from a diff by Ross L Richardson. --- lib/libc/gen/directory.3 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/libc/gen') diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 index 160ac912621..f892c4a9b88 100644 --- a/lib/libc/gen/directory.3 +++ b/lib/libc/gen/directory.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: directory.3,v 1.24 2015/11/10 23:48:18 jmc Exp $ +.\" $OpenBSD: directory.3,v 1.25 2017/09/18 15:57:02 millert Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: November 10 2015 $ +.Dd $Mdocdate: September 18 2017 $ .Dt OPENDIR 3 .Os .Sh NAME @@ -129,6 +129,9 @@ must be large enough for a dirent with a array member containing at least .Dv NAME_MAX plus one elements. +.Fn readdir_r +returns 0 on success, or an error number if an error occurs; see +.Sx ERRORS . On successful return, the pointer returned at .Fa "*result" will have the same value as the argument @@ -200,12 +203,12 @@ if (dirp) { while ((dp = readdir(dirp)) != NULL) if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { - (void)closedir(dirp); - return (FOUND); + closedir(dirp); + return FOUND; } - (void)closedir(dirp); + closedir(dirp); } -return (NOT_FOUND); +return NOT_FOUND; .Ed .Sh ERRORS The -- cgit v1.2.3