summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2013-11-05 20:36:52 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2013-11-05 20:36:52 +0000
commit5fd73121dd5f0d0304bb27597049614c51835609 (patch)
tree49b89b7ccb2a1c35d20003fb6c3e0cd48d2eb318 /lib/libc
parent4ca0f23bbab883d9309f33e64c977e6d5c5e9261 (diff)
Cleanup, no functional change:
1. avoid code duplication in rewinddir() by calling seekdir() directly 2. move __seekdir() into seekdir() and _telldir_unlocked() into telldir() Both functions were called from nowhere else. 3. remove some unused #include directives and one unused function prototype ok otto@ millert@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/rewinddir.c10
-rw-r--r--lib/libc/gen/seekdir.c10
-rw-r--r--lib/libc/gen/telldir.c28
-rw-r--r--lib/libc/gen/telldir.h5
4 files changed, 12 insertions, 41 deletions
diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c
index 3844b63efdb..49e7a435cee 100644
--- a/lib/libc/gen/rewinddir.c
+++ b/lib/libc/gen/rewinddir.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rewinddir.c,v 1.10 2013/08/13 05:52:12 guenther Exp $ */
-/*-
+/* $OpenBSD: rewinddir.c,v 1.11 2013/11/05 20:36:51 schwarze Exp $ */
+/*
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -28,16 +28,12 @@
* SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <dirent.h>
-
#include "thread_private.h"
#include "telldir.h"
void
rewinddir(DIR *dirp)
{
- _MUTEX_LOCK(&dirp->dd_lock);
- __seekdir(dirp, 0);
- _MUTEX_UNLOCK(&dirp->dd_lock);
+ seekdir(dirp, 0);
}
diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c
index 2affbdd1ef1..66c9bbca209 100644
--- a/lib/libc/gen/seekdir.c
+++ b/lib/libc/gen/seekdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: seekdir.c,v 1.9 2007/06/05 18:11:48 kurt Exp $ */
+/* $OpenBSD: seekdir.c,v 1.10 2013/11/05 20:36:51 schwarze Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -28,19 +28,21 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <dirent.h>
+#include <unistd.h>
+
#include "thread_private.h"
#include "telldir.h"
/*
* Seek to an entry in a directory.
- * __seekdir is in telldir.c so that it can share opaque data structures.
+ * Only values returned by "telldir" should be passed to seekdir.
*/
void
seekdir(DIR *dirp, long loc)
{
_MUTEX_LOCK(&dirp->dd_lock);
- __seekdir(dirp, loc);
+ dirp->dd_loc = 0;
+ dirp->dd_curpos = lseek(dirp->dd_fd, loc, SEEK_SET);
_MUTEX_UNLOCK(&dirp->dd_lock);
}
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index 4791fab008c..c12f0f56298 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: telldir.c,v 1.16 2013/11/05 09:36:05 schwarze Exp $ */
+/* $OpenBSD: telldir.c,v 1.17 2013/11/05 20:36:51 schwarze Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -28,45 +28,21 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-#include <sys/queue.h>
#include <dirent.h>
-#include <stdlib.h>
-#include <unistd.h>
-
#include "thread_private.h"
#include "telldir.h"
-int _readdir_unlocked(DIR *, struct dirent **, int);
-
/*
* return a pointer into a directory
*/
long
-_telldir_unlocked(DIR *dirp)
-{
- return (dirp->dd_curpos);
-}
-
-long
telldir(DIR *dirp)
{
long i;
_MUTEX_LOCK(&dirp->dd_lock);
- i = _telldir_unlocked(dirp);
+ i = dirp->dd_curpos;
_MUTEX_UNLOCK(&dirp->dd_lock);
return (i);
}
-
-/*
- * seek to an entry in a directory.
- * Only values returned by "telldir" should be passed to seekdir.
- */
-void
-__seekdir(DIR *dirp, long loc)
-{
- dirp->dd_loc = 0;
- dirp->dd_curpos = lseek(dirp->dd_fd, loc, SEEK_SET);
-}
diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h
index ab3fb4b920d..87a8b0d3501 100644
--- a/lib/libc/gen/telldir.h
+++ b/lib/libc/gen/telldir.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: telldir.h,v 1.6 2013/08/13 05:52:13 guenther Exp $ */
+/* $OpenBSD: telldir.h,v 1.7 2013/11/05 20:36:51 schwarze Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -47,7 +47,4 @@ struct _dirdesc {
void *dd_lock; /* mutex to protect struct */
};
-long _telldir_unlocked(DIR *);
-void __seekdir(DIR *, long);
-
#endif