X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/f2753d64be0a74a22018e03ec9c04cc9ca45d3ab..94187a80bd60baab4b9c4b949ad820d730578123:/sbr/lock_file.c diff --git a/sbr/lock_file.c b/sbr/lock_file.c index c7002b2e..2c8b1c75 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -17,6 +17,7 @@ #include #include #include +#include "lock_file.h" #include "m_mktemp.h" #ifdef HAVE_SYS_TIME_H @@ -89,7 +90,7 @@ static int lkopen_lockf (const char *, int, mode_t, int *); static int lkopen_flock (const char *, int, mode_t, int *); #endif /* HAVE_FLOCK */ -static enum locktype init_locktype(const char *); +static enum locktype init_locktype(const char *) PURE; static int lkopen_dot (const char *, int, mode_t, int *); static void lkclose_dot (int, const char *); @@ -521,6 +522,7 @@ lkopen_dot (const char *file, int access, mode_t mode, int *failed_to_lock) lockname (file, &lkinfo, 1); } + close(fd); *failed_to_lock = 1; return -1; } @@ -574,7 +576,7 @@ lockit (struct lockinfo *li) fd = link(tmpfile, curlock); (void) m_unlink(tmpfile); - return (fd == -1 ? -1 : 0); + return fd == -1 ? -1 : 0; } #endif /* HAVE_LIBLOCKFILE */ @@ -627,7 +629,9 @@ lockname (const char *file, struct lockinfo *li, int isnewlock) snprintf (bp, sizeof(li->curlock) - bplen, "%s.lock", cp); -#if !defined(HAVE_LIBLOCKFILE) +#if defined(HAVE_LIBLOCKFILE) + NMH_UNUSED(isnewlock); +#else /* * If this is for a new lock, create a name for * the temporary lock file for lockit()