Adding definition of CYNARA_NO_LOGS in top-level CMake enables build
with all logs disabled. Unfortunately such a build would fail in few files.
This patch fixes those files, enabling log-less build.
Change-Id: Ib2ab690ff1774f987d2d498a27709a968985ae6d
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD")
ENDIF (BUILD_WITH_SYSTEMD)
ADD_DEFINITIONS("-DBUILD_WITH_SYSTEMD")
ENDIF (BUILD_WITH_SYSTEMD)
+IF (CYNARA_NO_LOGS)
+ ADD_DEFINITIONS("-DCYNARA_NO_LOGS")
+ENDIF (CYNARA_NO_LOGS)
+
SET(TARGET_CYNARA "cynara")
SET(TARGET_LIB_CYNARA "cynara-client")
SET(TARGET_LIB_CYNARA_ASYNC "cynara-client-async")
SET(TARGET_CYNARA "cynara")
SET(TARGET_LIB_CYNARA "cynara-client")
SET(TARGET_LIB_CYNARA_ASYNC "cynara-client-async")
PolicyResult result;
ret = requestSimpleResult(key, result);
if (ret != CYNARA_API_SUCCESS) {
PolicyResult result;
ret = requestSimpleResult(key, result);
if (ret != CYNARA_API_SUCCESS) {
- if (ret != CYNARA_API_ACCESS_NOT_RESOLVED)
+ if (ret != CYNARA_API_ACCESS_NOT_RESOLVED) {
LOGE("Error fetching response for simpleCheck.");
LOGE("Error fetching response for simpleCheck.");
#include <cstring>
#include <stdlib.h>
#include <cstring>
#include <stdlib.h>
#ifdef BUILD_TYPE_DEBUG
int __log_level = LOG_DEBUG;
#else
#ifdef BUILD_TYPE_DEBUG
int __log_level = LOG_DEBUG;
#else
__log_level = strlog2intlog(env_val);
}
}
__log_level = strlog2intlog(env_val);
}
}
+
+#else
+
+void init_log(void) {}
+
+#endif //CYNARA_NO_LOGS
#include <dlfcn.h>
#include <functional>
#include <dlfcn.h>
#include <functional>
+#include <attributes/attributes.h>
#include <exceptions/UnknownPolicyTypeException.h>
#include <log/log.h>
#include <exceptions/UnknownPolicyTypeException.h>
#include <log/log.h>
int fileAmount = scandir(m_dir.c_str(), &nameList, pluginFilter, alphasort);
if (fileAmount < 0) {
int fileAmount = scandir(m_dir.c_str(), &nameList, pluginFilter, alphasort);
if (fileAmount < 0) {
- auto error = strerror(errno);
- LOGE("Couldn't scan for plugins in <%s> : <%s>", m_dir.c_str(), error);
+ UNUSED int err = errno;
+ LOGE("Couldn't scan for plugins in <%s> : <%s>", m_dir.c_str(), strerror(err));
#include <systemd/sd-daemon.h>
#endif
#include <systemd/sd-daemon.h>
#endif
+#include <attributes/attributes.h>
#include <log/log.h>
#include <common.h>
#include <config/PathConfig.h>
#include <log/log.h>
#include <common.h>
#include <config/PathConfig.h>
unsigned int clientLen = sizeof(clientAddr);
int clientFd = accept4(fd, (struct sockaddr*) &clientAddr, &clientLen, SOCK_NONBLOCK);
if (clientFd == -1) {
unsigned int clientLen = sizeof(clientAddr);
int clientFd = accept4(fd, (struct sockaddr*) &clientAddr, &clientLen, SOCK_NONBLOCK);
if (clientFd == -1) {
+ UNUSED int err = errno;
LOGW("Error in accept on socket [%d]: <%s>", fd, strerror(err));
return;
}
LOGW("Error in accept on socket [%d]: <%s>", fd, strerror(err));
return;
}
int fd;
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
int fd;
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
+ UNUSED int err = errno;
LOGE("Error during UNIX socket creation: <%s>", strerror(err));
throw InitException();
}
LOGE("Error during UNIX socket creation: <%s>", strerror(err));
throw InitException();
}
if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
flags = 0;
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
flags = 0;
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
+ UNUSED int err = errno;
close(fd);
LOGE("Error setting \"O_NONBLOCK\" on descriptor [%d] with fcntl: <%s>",
fd, strerror(err));
close(fd);
LOGE("Error setting \"O_NONBLOCK\" on descriptor [%d] with fcntl: <%s>",
fd, strerror(err));
originalUmask = umask(mask);
if (bind(fd, (struct sockaddr*)&serverAddress, sizeof(serverAddress)) == -1) {
originalUmask = umask(mask);
if (bind(fd, (struct sockaddr*)&serverAddress, sizeof(serverAddress)) == -1) {
+ UNUSED int err = errno;
close(fd);
LOGE("Error in bind socket descriptor [%d] to path <%s>: <%s>",
fd, path.c_str(), strerror(err));
close(fd);
LOGE("Error in bind socket descriptor [%d] to path <%s>: <%s>",
fd, path.c_str(), strerror(err));
umask(originalUmask);
if (listen(fd, 5) == -1) {
umask(originalUmask);
if (listen(fd, 5) == -1) {
+ UNUSED int err = errno;
close(fd);
LOGE("Error setting listen on file descriptor [%d], path <%s>: <%s>",
fd, path.c_str(), strerror(err));
close(fd);
LOGE("Error setting listen on file descriptor [%d], path <%s>: <%s>",
fd, path.c_str(), strerror(err));