From e00c635ef7139927fece424d10409953724a6c10 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sat, 20 Mar 2021 12:42:31 +0100 Subject: [PATCH] Fix tests and warnings --- CMakeLists.txt | 2 ++ FlashMQTests/FlashMQTests.pro | 22 +++++++++++++++++++++- logger.cpp | 1 + utils.cpp | 4 ++-- utils.h | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb48e9e..7f0f73f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_CXX_FLAGS "-rdynamic") +add_compile_options(-Wall) + add_executable(FlashMQ mainapp.cpp main.cpp diff --git a/FlashMQTests/FlashMQTests.pro b/FlashMQTests/FlashMQTests.pro index 96ca9fb..3080fab 100644 --- a/FlashMQTests/FlashMQTests.pro +++ b/FlashMQTests/FlashMQTests.pro @@ -28,6 +28,16 @@ SOURCES += tst_maintests.cpp \ ../authplugin.cpp \ ../session.cpp \ ../configfileparser.cpp \ + ../sslctxmanager.cpp \ + ../timer.cpp \ + ../iowrapper.cpp \ + ../mosquittoauthoptcompatwrap.cpp \ + ../settings.cpp \ + ../listener.cpp \ + ../unscopedlock.cpp \ + ../scopedsocket.cpp \ + ../bindaddr.cpp \ + ../oneinstancelock.cpp \ mainappthread.cpp \ twoclienttestcontext.cpp @@ -49,9 +59,19 @@ HEADERS += \ ../authplugin.h \ ../session.h \ ../configfileparser.h \ + ../sslctxmanager.h \ + ../timer.h \ + ../iowrapper.h \ + ../mosquittoauthoptcompatwrap.h \ + ../settings.h \ + ../listener.h \ + ../unscopedlock.h \ + ../scopedsocket.h \ + ../bindaddr.h \ + ../oneinstancelock.h \ mainappthread.h \ twoclienttestcontext.h -LIBS += -ldl +LIBS += -ldl -lssl -lcrypto QMAKE_LFLAGS += -rdynamic diff --git a/logger.cpp b/logger.cpp index 5487fa8..b8a8e2d 100644 --- a/logger.cpp +++ b/logger.cpp @@ -145,4 +145,5 @@ int logSslError(const char *str, size_t len, void *u) { Logger *logger = Logger::getInstance(); logger->logf(LOG_ERR, str); + return 0; } diff --git a/utils.cpp b/utils.cpp index 04d65e8..b6f819c 100644 --- a/utils.cpp +++ b/utils.cpp @@ -207,10 +207,10 @@ int64_t currentMSecsSinceEpoch() return milliseconds; } -std::string getSecureRandomString(const size_t len) +std::string getSecureRandomString(const ssize_t len) { std::vector buf(len); - size_t actual_len = getrandom(buf.data(), len, 0); + ssize_t actual_len = getrandom(buf.data(), len, 0); if (actual_len < 0 || actual_len != len) { diff --git a/utils.h b/utils.h index d54ea4d..27ca9cc 100644 --- a/utils.h +++ b/utils.h @@ -45,7 +45,7 @@ void trim(std::string &s); bool startsWith(const std::string &s, const std::string &needle); int64_t currentMSecsSinceEpoch(); -std::string getSecureRandomString(const size_t len); +std::string getSecureRandomString(const ssize_t len); std::string str_tolower(std::string s); bool stringTruthiness(const std::string &val); bool isPowerOfTwo(int val); -- libgit2 0.21.4