From 2a1ff598dbdd4ec91ec02c30cbd109d386ea98e7 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Sat, 15 Feb 2003 22:46:05 +0000
Subject: [PATCH] fcntl() retuns "Value other than -1" on fail, not negative on
 fail.

---
 src/xpdev/filewrap.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/xpdev/filewrap.c b/src/xpdev/filewrap.c
index 39ba046cd6..dd4cb5c552 100644
--- a/src/xpdev/filewrap.c
+++ b/src/xpdev/filewrap.c
@@ -85,7 +85,7 @@ int DLLCALL lock(int fd, long pos, int len)
 	int	flags;
  	struct flock alock;
 
-	if((flags=fcntl(fd,F_GETFL))<0)
+	if((flags=fcntl(fd,F_GETFL))==-1)
 		return -1;
 
 	if(flags==O_RDONLY)
@@ -96,7 +96,9 @@ int DLLCALL lock(int fd, long pos, int len)
 	alock.l_start = pos;
 	alock.l_len = len;
 
-	return fcntl(fd, F_SETLK, &alock);
+	if(fcntl(fd, F_SETLK, &alock)==-1)
+		return(-1);
+	return(0);
 }
 
 /* Removes a lock from a file record */
@@ -108,7 +110,9 @@ int DLLCALL unlock(int fd, long pos, int len)
 	alock.l_whence = L_SET;
 	alock.l_start = pos;
 	alock.l_len = len;
-	return fcntl(fd, F_SETLK, &alock);
+	if(fcntl(fd, F_SETLK, &alock)==-1)
+		return(-1);
+	return(0);
 }
 
 /* Opens a file in specified sharing (file-locking) mode */
@@ -129,7 +133,7 @@ int DLLCALL sopen(char *fn, int access, int share)
 	alock.l_start = 0;
 	alock.l_len = 0;       // lock to EOF
 
-	if (fcntl(fd, F_SETLK, &alock) < 0) {
+	if (fcntl(fd, F_SETLK, &alock) == -1) {
 		close(fd);
 		return -1;
 	}
-- 
GitLab