mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
Add GNU -Werror & fix warnings (#801)
This commit is contained in:
parent
4eeba18088
commit
44a8a2d5f7
@ -66,6 +66,10 @@ else (BUILD_DROGON_SHARED)
|
||||
add_library(${PROJECT_NAME} STATIC)
|
||||
endif (BUILD_DROGON_SHARED)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
|
||||
endif()
|
||||
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
|
||||
|
||||
|
@ -22,22 +22,22 @@ using namespace drogon::orm;
|
||||
using namespace drogon;
|
||||
|
||||
void DbClientManager::createDbClients(
|
||||
const std::vector<trantor::EventLoop *> &ioloops)
|
||||
const std::vector<trantor::EventLoop *> & /*ioloops*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void DbClientManager::createDbClient(const std::string &dbType,
|
||||
const std::string &host,
|
||||
const unsigned short port,
|
||||
const std::string &databaseName,
|
||||
const std::string &userName,
|
||||
const std::string &password,
|
||||
const size_t connectionNum,
|
||||
const std::string &filename,
|
||||
const std::string &name,
|
||||
const bool isFast,
|
||||
const std::string &characterSet)
|
||||
void DbClientManager::createDbClient(const std::string & /*dbType*/,
|
||||
const std::string & /*host*/,
|
||||
const unsigned short /*port*/,
|
||||
const std::string & /*databaseName*/,
|
||||
const std::string & /*userName*/,
|
||||
const std::string & /*password*/,
|
||||
const size_t /*connectionNum*/,
|
||||
const std::string & /*filename*/,
|
||||
const std::string & /*name*/,
|
||||
const bool /*isFast*/,
|
||||
const std::string & /*characterSet*/)
|
||||
{
|
||||
LOG_FATAL << "No database is supported by drogon, please install the "
|
||||
"database development library first.";
|
||||
|
@ -1012,7 +1012,8 @@ const HttpResponsePtr &HttpAppFrameworkImpl::getCustom404Page()
|
||||
static IOThreadStorage<HttpResponsePtr> thread404Pages;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [this] {
|
||||
thread404Pages.init([this](HttpResponsePtr &resp, size_t index) {
|
||||
thread404Pages.init(
|
||||
[this](HttpResponsePtr &resp, size_t /*index*/) {
|
||||
resp = std::make_shared<HttpResponseImpl>(
|
||||
*static_cast<HttpResponseImpl *>(custom404_.get()));
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ void HttpControllersRouter::doWhenNoHandlerFound(
|
||||
}
|
||||
|
||||
void HttpControllersRouter::init(
|
||||
const std::vector<trantor::EventLoop *> &ioLoops)
|
||||
const std::vector<trantor::EventLoop *> & /*ioLoops*/)
|
||||
{
|
||||
for (auto &router : ctrlVector_)
|
||||
{
|
||||
@ -537,7 +537,7 @@ void HttpControllersRouter::route(
|
||||
|
||||
void HttpControllersRouter::doControllerHandler(
|
||||
const CtrlBinderPtr &ctrlBinderPtr,
|
||||
const HttpControllerRouterItem &routerItem,
|
||||
const HttpControllerRouterItem & /*routerItem*/,
|
||||
const HttpRequestImplPtr &req,
|
||||
const std::smatch &matchResult,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback)
|
||||
|
@ -45,7 +45,7 @@ class HttpMessageBody
|
||||
}
|
||||
virtual const std::string &getString() const = 0;
|
||||
virtual std::string &getString() = 0;
|
||||
virtual void append(const char *buf, size_t len)
|
||||
virtual void append(const char * /*buf*/, size_t /*len*/)
|
||||
{
|
||||
}
|
||||
virtual ~HttpMessageBody()
|
||||
|
@ -134,7 +134,7 @@ HttpResponsePtr HttpResponse::newNotFoundResponse()
|
||||
static IOThreadStorage<HttpResponsePtr> thread404Pages;
|
||||
std::call_once(threadOnce, [] {
|
||||
thread404Pages.init(
|
||||
[](drogon::HttpResponsePtr &resp, size_t index) {
|
||||
[](drogon::HttpResponsePtr &resp, size_t /*index*/) {
|
||||
if (HttpAppFrameworkImpl::instance()
|
||||
.isUsingCustomErrorHandler())
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ HttpSimpleControllersRouter::getHandlersInfo() const
|
||||
}
|
||||
|
||||
void HttpSimpleControllersRouter::init(
|
||||
const std::vector<trantor::EventLoop *> &ioLoops)
|
||||
const std::vector<trantor::EventLoop *> & /*ioLoops*/)
|
||||
{
|
||||
for (auto &iter : simpleCtrlMap_)
|
||||
{
|
||||
|
@ -22,17 +22,17 @@ using namespace drogon::nosql;
|
||||
using namespace drogon;
|
||||
|
||||
void RedisClientManager::createRedisClients(
|
||||
const std::vector<trantor::EventLoop *> &ioloops)
|
||||
const std::vector<trantor::EventLoop *> & /*ioloops*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void RedisClientManager::createRedisClient(const std::string &name,
|
||||
const std::string &host,
|
||||
unsigned short port,
|
||||
const std::string &password,
|
||||
size_t connectionNum,
|
||||
bool isFast)
|
||||
void RedisClientManager::createRedisClient(const std::string & /*name*/,
|
||||
const std::string & /*host*/,
|
||||
unsigned short /*port*/,
|
||||
const std::string & /*password*/,
|
||||
size_t /*connectionNum*/,
|
||||
bool /*isFast*/)
|
||||
{
|
||||
LOG_FATAL << "Redis is not supported by drogon, please install the "
|
||||
"hiredis library first.";
|
||||
|
@ -19,9 +19,9 @@ namespace drogon
|
||||
namespace nosql
|
||||
{
|
||||
std::shared_ptr<RedisClient> RedisClient::newRedisClient(
|
||||
const trantor::InetAddress &serverAddress,
|
||||
size_t numberOfConnections,
|
||||
const std::string &password)
|
||||
const trantor::InetAddress& /*serverAddress*/,
|
||||
size_t /*numberOfConnections*/,
|
||||
const std::string& /*password*/)
|
||||
{
|
||||
LOG_FATAL << "Redis is not supported by drogon, please install the "
|
||||
"hiredis library first.";
|
||||
|
@ -27,7 +27,7 @@ std::string RedisResult::getStringForDisplaying() const noexcept
|
||||
}
|
||||
|
||||
std::string RedisResult::getStringForDisplayingWithIndent(
|
||||
size_t indent) const noexcept
|
||||
size_t /*indent*/) const noexcept
|
||||
{
|
||||
LOG_FATAL << "Redis is not supported by drogon, please install the "
|
||||
"hiredis library first.";
|
||||
|
@ -20,7 +20,6 @@ using namespace drogon;
|
||||
SessionManager::SessionManager(trantor::EventLoop *loop, size_t timeout)
|
||||
: loop_(loop), timeout_(timeout)
|
||||
{
|
||||
assert(timeout_ >= 0);
|
||||
if (timeout_ > 0)
|
||||
{
|
||||
size_t wheelNum = 1;
|
||||
|
@ -36,7 +36,7 @@ class SharedLibManager : public trantor::NonCopyable
|
||||
struct DLStat
|
||||
{
|
||||
void *handle{nullptr};
|
||||
struct timespec mTime = {0};
|
||||
struct timespec mTime = {0, 0};
|
||||
};
|
||||
std::unordered_map<std::string, DLStat> dlMap_;
|
||||
void *compileAndLoadLib(const std::string &sourceFile, void *oldHld);
|
||||
|
@ -830,7 +830,20 @@ std::string urlDecode(const char *begin, const char *end)
|
||||
/* Compress gzip data */
|
||||
std::string gzipCompress(const char *data, const size_t ndata)
|
||||
{
|
||||
z_stream strm = {0};
|
||||
z_stream strm = {nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
if (data && ndata > 0)
|
||||
{
|
||||
if (deflateInit2(&strm,
|
||||
@ -884,7 +897,20 @@ std::string gzipDecompress(const char *data, const size_t ndata)
|
||||
auto decompressed = std::string(full_length * 2, 0);
|
||||
bool done = false;
|
||||
|
||||
z_stream strm = {0};
|
||||
z_stream strm = {nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
strm.next_in = (Bytef *)data;
|
||||
strm.avail_in = static_cast<uInt>(ndata);
|
||||
strm.total_out = 0;
|
||||
|
@ -43,11 +43,11 @@ class RedisException final : public std::exception
|
||||
return code_;
|
||||
}
|
||||
RedisException(RedisErrorCode code, const std::string &message)
|
||||
: code_(code), message_(message)
|
||||
: message_(message), code_(code)
|
||||
{
|
||||
}
|
||||
RedisException(RedisErrorCode code, std::string &&message)
|
||||
: code_(code), message_(std::move(message))
|
||||
: message_(std::move(message)), code_(code)
|
||||
{
|
||||
}
|
||||
RedisException() = delete;
|
||||
|
@ -38,6 +38,8 @@ std::shared_ptr<DbClient> DbClient::newPgClient(const std::string &connInfo,
|
||||
#else
|
||||
LOG_FATAL << "PostgreSQL is not supported!";
|
||||
exit(1);
|
||||
(void)(connInfo);
|
||||
(void)(connNum);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -49,6 +51,8 @@ std::shared_ptr<DbClient> DbClient::newMysqlClient(const std::string &connInfo,
|
||||
#else
|
||||
LOG_FATAL << "Mysql is not supported!";
|
||||
exit(1);
|
||||
(void)(connInfo);
|
||||
(void)(connNum);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -63,5 +67,7 @@ std::shared_ptr<DbClient> DbClient::newSqlite3Client(
|
||||
#else
|
||||
LOG_FATAL << "Sqlite3 is not supported!";
|
||||
exit(1);
|
||||
(void)(connInfo);
|
||||
(void)(connNum);
|
||||
#endif
|
||||
}
|
||||
|
@ -369,6 +369,7 @@ DbConnectionPtr DbClientImpl::newConnection(trantor::EventLoop *loop)
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
(void)(loop);
|
||||
}
|
||||
|
||||
std::weak_ptr<DbClientImpl> weakPtr = shared_from_this();
|
||||
|
@ -327,5 +327,6 @@ int SqlBinder::getMysqlTypeBySize(size_t size)
|
||||
LOG_FATAL << "Mysql is not supported!";
|
||||
exit(1);
|
||||
return 0;
|
||||
(void)(size);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user