Skip to content
Snippets Groups Projects
Commit 2a1ff598 authored by deuce's avatar deuce
Browse files

fcntl() retuns "Value other than -1" on fail, not negative on fail.

parent 49ef7223
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ int DLLCALL lock(int fd, long pos, int len) ...@@ -85,7 +85,7 @@ int DLLCALL lock(int fd, long pos, int len)
int flags; int flags;
struct flock alock; struct flock alock;
if((flags=fcntl(fd,F_GETFL))<0) if((flags=fcntl(fd,F_GETFL))==-1)
return -1; return -1;
if(flags==O_RDONLY) if(flags==O_RDONLY)
...@@ -96,7 +96,9 @@ int DLLCALL lock(int fd, long pos, int len) ...@@ -96,7 +96,9 @@ int DLLCALL lock(int fd, long pos, int len)
alock.l_start = pos; alock.l_start = pos;
alock.l_len = len; 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 */ /* Removes a lock from a file record */
...@@ -108,7 +110,9 @@ int DLLCALL unlock(int fd, long pos, int len) ...@@ -108,7 +110,9 @@ int DLLCALL unlock(int fd, long pos, int len)
alock.l_whence = L_SET; alock.l_whence = L_SET;
alock.l_start = pos; alock.l_start = pos;
alock.l_len = len; 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 */ /* Opens a file in specified sharing (file-locking) mode */
...@@ -129,7 +133,7 @@ int DLLCALL sopen(char *fn, int access, int share) ...@@ -129,7 +133,7 @@ int DLLCALL sopen(char *fn, int access, int share)
alock.l_start = 0; alock.l_start = 0;
alock.l_len = 0; // lock to EOF alock.l_len = 0; // lock to EOF
if (fcntl(fd, F_SETLK, &alock) < 0) { if (fcntl(fd, F_SETLK, &alock) == -1) {
close(fd); close(fd);
return -1; return -1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment