drogonframework / drogonframework/drogon

编译器警告

Open
#2,306 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 12h
Merged PRs (30d)
15

Description

```
/root/http_util/third_party/drogon/lib/src/SlidingWindowRateLimiter.cc: In member function ‘virtual bool drogon::SlidingWindowRateLimiter::isAllowed()’:
/root/http_util/third_party/drogon/lib/src/SlidingWindowRateLimiter.cc:37:14: warning: variable ‘startTime’ set but not used [-Wunused-but-set-variable]
37 | auto startTime = lastTime_;
| ^~~~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpUtils.cc:62:10: warning: ‘drogon::CT_APPLICATION_X_JAVASCRIPT’ is deprecated: use CT_TEXT_JAVASCRIPT [-Wdeprecated-declarations]
62 | {CT_APPLICATION_X_JAVASCRIPT,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /root/http_util/third_party/drogon/lib/src/HttpUtils.h:18,
from /root/http_util/third_party/drogon/lib/src/HttpUtils.cc:15:
/root/http_util/third_party/drogon/lib/inc/drogon/HttpTypes.h:106:5: note: declared here
106 | CT_APPLICATION_X_JAVASCRIPT [[deprecated("use CT_TEXT_JAVASCRIPT")]],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpUtils.cc: In lambda function:
/root/http_util/third_party/drogon/lib/src/HttpUtils.cc:733:23: warning: ‘drogon::CT_APPLICATION_X_JAVASCRIPT’ is deprecated: use CT_TEXT_JAVASCRIPT [-Wdeprecated-declarations]
733 | extensionMap_[CT_APPLICATION_X_JAVASCRIPT] =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/lib/inc/drogon/HttpTypes.h:106:5: note: declared here
106 | CT_APPLICATION_X_JAVASCRIPT [[deprecated("use CT_TEXT_JAVASCRIPT")]],
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/lib/src/Utilities.cc: In function ‘void drogon::utils::dateToCustomFormattedString(const std::string&, std::string&, const trantor::Date&)’:
/root/http_util/third_party/drogon/lib/src/Utilities.cc:1042:12: warning: unused variable ‘seconds’ [-Wunused-variable]
1042 | time_t seconds = static_cast(nowSecond);
| ^~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpClientImpl.cc: In member function ‘void drogon::HttpClientImpl::handleResponse(const drogon::HttpResponseImplPtr&, std::pair, std::function&)> >&&, const trantor::TcpConnectionPtr&)’:
/root/http_util/third_party/drogon/lib/src/HttpClientImpl.cc:552:11: warning: unused variable ‘type’ [-Wunused-variable]
552 | auto &type = resp->getHeaderBy("content-type");
| ^~~~
/root/http_util/third_party/drogon/lib/src/AccessLogger.cc: In member function ‘virtual void drogon::plugin::AccessLogger::initAndStart(const Json::Value&)’:
/root/http_util/third_party/drogon/lib/src/AccessLogger.cc:263:22: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
263 | if (maxFiles >= 0)
| ~~~~~~~~~^~~~
/root/http_util/third_party/drogon/lib/src/HttpResponseImpl.cc: In static member function ‘static drogon::HttpResponsePtr drogon::HttpResponse::newStreamResponse(const std::function&, const std::string&, drogon::ContentType, const std::string&, const drogon::HttpRequestPtr&)’:
/root/http_util/third_party/drogon/lib/src/HttpResponseImpl.cc:426:18: warning: unused variable ‘contentType’ [-Wunused-variable]
426 | auto contentType = type;
| ^~~~~~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpResponseImpl.cc:446:18: warning: unused variable ‘contentType’ [-Wunused-variable]
446 | auto contentType = type;
| ^~~~~~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpServer.cc: In static member function ‘static void drogon::HttpServer::onMessage(const trantor::TcpConnectionPtr&, trantor::MsgBuffer*)’:
/root/http_util/third_party/drogon/lib/src/HttpServer.cc:222:44: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
222 | if (parseRes >= 2 || parseRes == 1 && !req->isStreamMode())
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc: In member function ‘virtual void drogon::HttpAppFrameworkImpl::addPlugin(const std::string&, const std::vector >&, const Json::Value&)’:
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc:379:21: warning: loop variable ‘dep’ creates a copy from type ‘const std::__cxx11::basic_string’ [-Wrange-loop-construct]
379 | for (const auto dep : dependencies)
| ^~~
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc:379:21: note: use reference type to prevent copying
379 | for (const auto dep : dependencies)
| ^~~
| &
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc: In member function ‘virtual void drogon::HttpAppFrameworkImpl::addPlugins(const Json::Value&)’:
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc:394:21: warning: loop variable ‘config’ creates a copy from type ‘const Json::Value’ [-Wrange-loop-construct]
394 | for (const auto config : configs)
| ^~~~~~
/root/http_util/third_party/drogon/lib/src/HttpAppFrameworkImpl.cc:394:21: note: use reference type to prevent copying
394 | for (const auto config : configs)

/root/http_util/third_party/drogon/examples/async_stream/RequestStreamExampleCtrl.cc: In lambda function:
/root/http_util/third_party/drogon/examples/async_stream/RequestStreamExampleCtrl.cc:89:33: warning: missing initializer for member ‘RequestStreamExampleCtrl::stream_upload(const drogon::HttpRequestPtr&, drogon::RequestStreamPtr&&, std::function&)>&&) const::Entry::tmpName’ [-Wmissing-field-initializers]
89 | files->push_back({std::move(header)});
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/examples/async_stream/RequestStreamExampleCtrl.cc:89:33: warning: missing initializer for member ‘RequestStreamExampleCtrl::stream_upload(const drogon::HttpRequestPtr&, drogon::RequestStreamPtr&&, std::function&)>&&) const::Entry::file’ [-Wmissing-field-initializers]

/root/http_util/third_party/drogon/drogon_ctl/version.cc: In member function ‘virtual void drogon_ctl::version::handleCommand(std::vector >&)’:
/root/http_util/third_party/drogon/drogon_ctl/version.cc:36:16: warning: unused variable ‘tlsSupported’ [-Wunused-variable]
36 | const bool tlsSupported = drogon::utils::supportsTls();
| ^~~~~~~~~~~~
[ 82%] Linking CXX shared library libhttp_util.so
[ 82%] Built target http_util
/root/http_util/third_party/drogon/drogon_ctl/create_model.cc:49:20: warning: ‘std::string escapeConnString(const std::string&)’ defined but not used [-Wunused-function]
49 | static std::string escapeConnString(const std::string &str)
| ^~~~~~~~~~~~~~~~
/root/http_util/third_party/drogon/drogon_ctl/create_model.cc:40:20: warning: ‘std::string toLower(const std::string&)’ defined but not used [-Wunused-function]
40 | static std::string toLower(const std::string &str)
```

有一些值得改的, 供您参考

Contributor guide

Open the contributing guide

Research direction

Reproduce the compiler warnings, then inspect the listed locations in lib/src/SlidingWindowRateLimiter.cc, HttpUtils.cc, Utilities.cc, HttpClientImpl.cc, AccessLogger.cc, HttpResponseImpl.cc, HttpServer.cc, HttpAppFrameworkImpl.cc, examples/async_stream/RequestStreamExampleCtrl.cc, and drogon_ctl/*.cc. Determine which warnings are actionable and verify that the project builds without the addressed warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.