From: Po Lu Date: Sun, 9 Jan 2022 13:30:26 +0000 (+0000) Subject: Fix filelock.c for Haiku X-Git-Tag: emacs-29.0.90~3173 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=691015fedbb94c69fd7d5b0fffe9df9715bb0158;p=emacs.git 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.) --- diff --git a/src/filelock.c b/src/filelock.c index a213c2b3cae..8453f17cd4b 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -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