X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/2e08fdfc0ef872c968c2e42b7ee0ede42aee14aa..3c516d410d256012f843944b0f43a77d8c1ac146:/sbr/lock_file.c diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 8506faf8..80b93a90 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -24,7 +24,6 @@ # include #endif #include -#include #include #ifdef HAVE_FLOCK # include @@ -33,8 +32,6 @@ # include #endif -#include - #if defined(HAVE_LIBLOCKFILE) #include #endif @@ -229,8 +226,13 @@ lkclosedata(int fd, const char *name) int lkfclosedata(FILE *f, const char *name) { - int fd = fileno(f); - int rc = fclose(f); + int fd, rc; + + if (f == NULL) + return 0; + + fd = fileno(f); + rc = fclose(f); if (datalocktype == DOT_LOCKING) lkclose_dot(fd, name); @@ -252,8 +254,13 @@ lkclosespool(int fd, const char *name) int lkfclosespool(FILE *f, const char *name) { - int fd = fileno(f); - int rc = fclose(f); + int fd, rc; + + if (f == NULL) + return 0; + + fd = fileno(f); + rc = fclose(f); if (spoollocktype == DOT_LOCKING) lkclose_dot(fd, name); @@ -735,21 +742,21 @@ alrmser (int sig) static enum locktype init_locktype(const char *lockname) { - if (mh_strcasecmp(lockname, "fcntl") == 0) { + if (strcasecmp(lockname, "fcntl") == 0) { return FCNTL_LOCKING; - } else if (mh_strcasecmp(lockname, "lockf") == 0) { + } else if (strcasecmp(lockname, "lockf") == 0) { #ifdef HAVE_LOCKF return LOCKF_LOCKING; #else /* ! HAVE_LOCKF */ adios(NULL, "lockf not supported on this system"); #endif /* HAVE_LOCKF */ - } else if (mh_strcasecmp(lockname, "flock") == 0) { + } else if (strcasecmp(lockname, "flock") == 0) { #ifdef HAVE_FLOCK return FLOCK_LOCKING; #else /* ! HAVE_FLOCK */ adios(NULL, "flock not supported on this system"); #endif /* HAVE_FLOCK */ - } else if (mh_strcasecmp(lockname, "dot") == 0) { + } else if (strcasecmp(lockname, "dot") == 0) { return DOT_LOCKING; } else { adios(NULL, "Unknown lock type: \"%s\"", lockname);