Ingo Schwarze wrote on Mon, Nov 04, 2013 at 09:51:41AM +0100:

> I will send a minimal one-line patch to just fix the bug and do nothing
> else.  We should get that one in quickly.

Done.

[...]
> Then i will send two cleanup patches to remove useless stuff
> and put the code into the right place, not changing any functionality.

Here it is (one patch only).

 - put the seekdir() implementation where it belongs
   and remove a related lie from a comment
 - remove unused headers and an unused prototype
 - remove two trivial functions used only once, in the same file
 - avoid code duplication

No functional change.

OK?
  Ingo


Index: rewinddir.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/rewinddir.c,v
retrieving revision 1.10
diff -u -p -r1.10 rewinddir.c
--- rewinddir.c 13 Aug 2013 05:52:12 -0000      1.10
+++ rewinddir.c 5 Nov 2013 09:54:32 -0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: rewinddir.c,v 1.10 2013/08/13 05:52:12 guenther 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);
 }
Index: seekdir.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/seekdir.c,v
retrieving revision 1.9
diff -u -p -r1.9 seekdir.c
--- seekdir.c   5 Jun 2007 18:11:48 -0000       1.9
+++ seekdir.c   5 Nov 2013 09:54:32 -0000
@@ -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);
 }
Index: telldir.c
===================================================================
RCS file: /cvs/src/lib/libc/gen/telldir.c,v
retrieving revision 1.16
diff -u -p -r1.16 telldir.c
--- telldir.c   5 Nov 2013 09:36:05 -0000       1.16
+++ telldir.c   5 Nov 2013 09:54:33 -0000
@@ -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);
 }
Index: telldir.h
===================================================================
RCS file: /cvs/src/lib/libc/gen/telldir.h,v
retrieving revision 1.6
diff -u -p -r1.6 telldir.h
--- telldir.h   13 Aug 2013 05:52:13 -0000      1.6
+++ telldir.h   5 Nov 2013 09:54:33 -0000
@@ -47,7 +47,4 @@ struct _dirdesc {
        void    *dd_lock;       /* mutex to protect struct */
 };
 
-long           _telldir_unlocked(DIR *);
-void           __seekdir(DIR *, long);
-
 #endif

Reply via email to