Make the other modules use error.c
This commit is contained in:
parent
6bc3ffde5d
commit
a2f2e58353
7 changed files with 26 additions and 32 deletions
12
lockfile.c
12
lockfile.c
|
|
@ -26,7 +26,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include "error.h"
|
||||
#include "lockfile.h"
|
||||
|
||||
#define locked(x) ((x)->fd >= 0)
|
||||
|
|
@ -95,13 +95,9 @@ int hold_lock(struct lockfile *lock, const char *filename, int force) {
|
|||
|
||||
lock->fd = open(lock->name, mask, 0600);
|
||||
if (lock->fd < 0) {
|
||||
if (errno == EEXIST) {
|
||||
fprintf(stderr, "'%s' is locked\n", lock->name);
|
||||
} else {
|
||||
fprintf(stderr, "unable to create lockfile '%s'",
|
||||
lock->name);
|
||||
}
|
||||
return -1;
|
||||
return error(errno == EEXIST ?
|
||||
"'%s' is locked\n" : "unable to create lockfile '%s'",
|
||||
lock->name);
|
||||
}
|
||||
lock->next = active_locks;
|
||||
active_locks = lock;
|
||||
|
|
|
|||
Reference in a new issue