git » libjio » commit 069b8bc

fseek() returns 0 on success and -1 on error; however our wrapper returns like lseek(). This patch fixes it and make the wrapper, jfseek(), behave correctly.

author Alberto Bertogli
2004-06-03 04:03:19 UTC
committer Alberto Bertogli
2007-07-15 13:02:29 UTC
parent 30c458170d4fa1a4aa3b038be3178e90754b912b

fseek() returns 0 on success and -1 on error; however our wrapper returns like lseek(). This patch fixes it and make the wrapper, jfseek(), behave correctly.

fseek() returns 0 on success and -1 on error; however our wrapper returns like
lseek(). This patch fixes it and make the wrapper, jfseek(), behave correctly.

ansi.c +5 -1

diff --git a/ansi.c b/ansi.c
index 054503b..8ded686 100644
--- a/ansi.c
+++ b/ansi.c
@@ -181,7 +181,11 @@ int jfseek(struct jfs *stream, long offset, int whence)
 	pos = lseek(stream->fd, offset, whence);
 	pthread_mutex_unlock(&(stream->lock));
 
-	return pos;
+	/* fseek returns 0 on success, -1 on error */
+	if (pos == -1)
+		return 1;
+
+	return 0;
 }
 
 /* ftell wrapper */