
In jclose(), before closing the descriptors check if they're opened to avoid
unnecesary close() calls.

They don't harm, but it looks cleaner if we don't do them (and makes straces
easier to follow).


---

 cur-root/trans.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff -puN trans.c~jclose_check_fd trans.c
--- cur/trans.c~jclose_check_fd	2004-08-30 01:30:39.653543176 -0300
+++ cur-root/trans.c	2004-08-30 01:30:39.657542568 -0300
@@ -598,6 +598,9 @@ int jsync(struct jfs *fs)
 	int rv;
 	struct jlinger *linger, *ltmp;
 
+	if (fs->fd < 0)
+		return -1;
+
 	rv = fsync(fs->fd);
 	if (rv != 0)
 		return rv;
@@ -628,11 +631,11 @@ int jclose(struct jfs *fs)
 
 	if (jsync(fs))
 		ret = -1;
-	if (close(fs->fd))
+	if (fs->fd < 0 || close(fs->fd))
 		ret = -1;
-	if (close(fs->jfd))
+	if (fs->jfd < 0 || close(fs->jfd))
 		ret = -1;
-	if (close(fs->jdirfd))
+	if (fs->jdirfd < 0 || close(fs->jdirfd))
 		ret = -1;
 	if (fs->name)
 		/* allocated by strdup() in jopen() */
_
