1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

Fix filelock.c for Haiku

This was found during the investigation surrounding bug#53136,
but is not directly related.

* src/filelock.c (lock_if_free): Explictly test err against -1
or -2, and reverse sign of system errors on Haiku.  (No Haiku
error occupies -1 or -2.)
This commit is contained in:
Po Lu 2022-01-09 13:30:26 +00:00
parent 54971f5c14
commit 691015fedb

View file

@ -608,7 +608,7 @@ lock_if_free (lock_info_type *clasher, char *lfname)
err = current_lock_owner (clasher, lfname);
if (err != 0)
{
if (err < 0)
if (err == -1 || err == -2)
return -2 - err; /* We locked it, or someone else has it. */
break; /* current_lock_owner returned strange error. */
}
@ -616,7 +616,14 @@ lock_if_free (lock_info_type *clasher, char *lfname)
/* We deleted a stale lock; try again to lock the file. */
}
#if !defined HAIKU \
|| defined BE_USE_POSITIVE_POSIX_ERRORS
return err;
#else
/* On Haiku, POSIX error values are negative by default, but this
code's callers assume that any errno value is positive. */
return -err;
#endif
}
static Lisp_Object