From ef2e50b94fbc7ce1c7dbe1f2ea860e6ab0724726 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sat, 3 Dec 2016 13:50:53 +0100 Subject: lib: Remove logs from stable sources This removes log output in applications and some size_t printf errors when compiling on 32 bit machines. --- src/lib/lockfile.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'src/lib/lockfile.c') diff --git a/src/lib/lockfile.c b/src/lib/lockfile.c index a0222f18..5c96d22a 100644 --- a/src/lib/lockfile.c +++ b/src/lib/lockfile.c @@ -23,15 +23,12 @@ #include #include -#define OUROBOROS_PREFIX "lockfile" - -#include - #include #include #include #include #include +#include #include #include @@ -52,7 +49,6 @@ struct lockfile * lockfile_create() { fd = shm_open(LOCKFILE_NAME, O_CREAT | O_EXCL | O_RDWR, 0666); if (fd == -1) { - LOG_DBGF("Could not create lock file."); free(lf); return NULL; } @@ -60,7 +56,6 @@ struct lockfile * lockfile_create() { umask(mask); if (ftruncate(fd, LF_SIZE - 1) < 0) { - LOG_DBGF("Failed to extend lockfile."); free(lf); return NULL; } @@ -74,9 +69,7 @@ struct lockfile * lockfile_create() { close (fd); if (lf->api == MAP_FAILED) { - LOG_DBGF("Failed to map lockfile."); - if (shm_unlink(LOCKFILE_NAME) == -1) - LOG_DBGF("Failed to remove invalid lockfile."); + shm_unlink(LOCKFILE_NAME); free(lf); return NULL; } @@ -94,7 +87,6 @@ struct lockfile * lockfile_open() { fd = shm_open(LOCKFILE_NAME, O_RDWR, 0666); if (fd < 0) { - LOG_DBGF("Could not open lock file."); free(lf); return NULL; } @@ -108,9 +100,7 @@ struct lockfile * lockfile_open() { close(fd); if (lf->api == MAP_FAILED) { - LOG_DBGF("Failed to map lockfile."); - if (shm_unlink(LOCKFILE_NAME) == -1) - LOG_DBGF("Failed to remove invalid lockfile."); + shm_unlink(LOCKFILE_NAME); free(lf); return NULL; } @@ -120,39 +110,30 @@ struct lockfile * lockfile_open() { void lockfile_close(struct lockfile * lf) { - if (lf == NULL) { - LOG_DBGF("Bogus input. Bugging out."); - return; - } + assert(lf); - if (munmap(lf->api, LF_SIZE) == -1) - LOG_DBGF("Couldn't unmap lockfile."); + munmap(lf->api, LF_SIZE); free(lf); } void lockfile_destroy(struct lockfile * lf) { - if (lf == NULL) { - LOG_DBGF("Bogus input. Bugging out."); - return; - } + assert(lf); - if (getpid() != *lf->api && kill(*lf->api, 0) == 0) { - LOG_DBGF("Only IRMd can destroy %s.", LOCKFILE_NAME); + if (getpid() != *lf->api && kill(*lf->api, 0) == 0) return; - } - if (munmap(lf->api, LF_SIZE) == -1) - LOG_DBGF("Couldn't unmap lockfile."); + munmap(lf->api, LF_SIZE); - if (shm_unlink(LOCKFILE_NAME) == -1) - LOG_DBGF("Failed to remove lockfile."); + shm_unlink(LOCKFILE_NAME); free(lf); } pid_t lockfile_owner(struct lockfile * lf) { + assert(lf); + return *lf->api; } -- cgit v1.2.3