Archived
1
0
Fork 0

Make the other modules use error.c

This commit is contained in:
Henrik Hautakoski 2011-08-04 11:10:08 +02:00
parent 6bc3ffde5d
commit a2f2e58353
7 changed files with 26 additions and 32 deletions

View file

@ -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;