Unverified Commit ea393877 authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #660 from dennisjenkins75/master

Fixed several cppcheck findings.
parents 2aaa2311 ddf64a13
...@@ -408,7 +408,7 @@ namespace Private { ...@@ -408,7 +408,7 @@ namespace Private {
StreamCursor::Token chunkData(cursor); StreamCursor::Token chunkData(cursor);
const ssize_t available = cursor.remaining(); const ssize_t available = cursor.remaining();
if ((available + message->body_.size()) < size) { if (static_cast<ssize_t>(available + message->body_.size()) < size) {
cursor.advance(available); cursor.advance(available);
message->body_.append(chunkData.rawText(), available); message->body_.append(chunkData.rawText(), available);
return Incomplete; return Incomplete;
...@@ -451,7 +451,7 @@ namespace Private { ...@@ -451,7 +451,7 @@ namespace Private {
State State
ParserBase::parse() { ParserBase::parse() {
State state = State::Again; State state;
do { do {
Step *step = allSteps[currentStep].get(); Step *step = allSteps[currentStep].get();
state = step->apply(cursor); state = step->apply(cursor);
......
...@@ -195,8 +195,8 @@ private: ...@@ -195,8 +195,8 @@ private:
uint64_t value; uint64_t value;
std::tie(index, value) = decodeTag(event.tag); std::tie(index, value) = decodeTag(event.tag);
auto handler = handlers_.at(index); auto handler_ = handlers_.at(index);
auto& evs = fdHandlers.at(handler); auto& evs = fdHandlers.at(handler_);
evs.push_back(std::move(event)); evs.push_back(std::move(event));
} }
...@@ -460,10 +460,11 @@ private: ...@@ -460,10 +460,11 @@ private:
struct Worker { struct Worker {
explicit Worker(Reactor* reactor, const std::string& threadsName) { explicit Worker(Reactor* reactor, const std::string& threadsName):
threadsName_ = threadsName; thread(),
sync.reset(new SyncImpl(reactor)); sync(new SyncImpl(reactor)),
} threadsName_(threadsName)
{ }
~Worker() { ~Worker() {
if (thread.joinable()) if (thread.joinable())
......
...@@ -84,8 +84,8 @@ Transport::onReady(const Aio::FdSet& fds) { ...@@ -84,8 +84,8 @@ Transport::onReady(const Aio::FdSet& fds) {
handleIncoming(peer); handleIncoming(peer);
} else if (isTimerFd(tag)) { } else if (isTimerFd(tag)) {
auto it = timers.find(tag.value()); auto it = timers.find(tag.value());
auto& entry = it->second; auto& entry_ = it->second;
handleTimer(std::move(entry)); handleTimer(std::move(entry_));
timers.erase(it->first); timers.erase(it->first);
} }
else { else {
...@@ -242,13 +242,14 @@ Transport::asyncWriteImpl(Fd fd) ...@@ -242,13 +242,14 @@ Transport::asyncWriteImpl(Fd fd)
auto ptr = raw.data().c_str() + totalWritten; auto ptr = raw.data().c_str() + totalWritten;
#ifdef PISTACHE_USE_SSL #ifdef PISTACHE_USE_SSL
auto it = peers.find(fd); auto it_ = peers.find(fd);
if (it == std::end(peers)) if (it_ == std::end(peers))
throw std::runtime_error("No peer found for fd: " + std::to_string(fd)); throw std::runtime_error("No peer found for fd: " + std::to_string(fd));
if (it->second->ssl() != NULL) { if (it_->second->ssl() != NULL) {
bytesWritten = SSL_write((SSL *)it->second->ssl(), ptr, len); auto ssl_ = static_cast<SSL*>(it_->second->ssl());
bytesWritten = SSL_write(ssl_, ptr, len);
} else { } else {
#endif /* PISTACHE_USE_SSL */ #endif /* PISTACHE_USE_SSL */
bytesWritten = ::send(fd, ptr, len, flags); bytesWritten = ::send(fd, ptr, len, flags);
...@@ -260,13 +261,14 @@ Transport::asyncWriteImpl(Fd fd) ...@@ -260,13 +261,14 @@ Transport::asyncWriteImpl(Fd fd)
off_t offset = totalWritten; off_t offset = totalWritten;
#ifdef PISTACHE_USE_SSL #ifdef PISTACHE_USE_SSL
auto it = peers.find(fd); auto it_ = peers.find(fd);
if (it == std::end(peers)) if (it_ == std::end(peers))
throw std::runtime_error("No peer found for fd: " + std::to_string(fd)); throw std::runtime_error("No peer found for fd: " + std::to_string(fd));
if (it->second->ssl() != NULL) { if (it_->second->ssl() != NULL) {
bytesWritten = SSL_sendfile((SSL *)it->second->ssl(), file, &offset, len); auto ssl_ = static_cast<SSL*>(it_->second->ssl());
bytesWritten = SSL_sendfile(ssl_, file, &offset, len);
} else { } else {
#endif /* PISTACHE_USE_SSL */ #endif /* PISTACHE_USE_SSL */
bytesWritten = ::sendfile(fd, file, &offset, len); bytesWritten = ::sendfile(fd, file, &offset, len);
......
...@@ -78,6 +78,7 @@ Listener::Listener() ...@@ -78,6 +78,7 @@ Listener::Listener()
, reactor_() , reactor_()
, transportKey() , transportKey()
, useSSL_(false) , useSSL_(false)
, ssl_ctx_(nullptr)
{ } { }
Listener::Listener(const Address& address) Listener::Listener(const Address& address)
...@@ -92,8 +93,8 @@ Listener::Listener(const Address& address) ...@@ -92,8 +93,8 @@ Listener::Listener(const Address& address)
, reactor_() , reactor_()
, transportKey() , transportKey()
, useSSL_(false) , useSSL_(false)
{ , ssl_ctx_(nullptr)
} { }
Listener::~Listener() { Listener::~Listener() {
if (isBound()) if (isBound())
......
...@@ -347,8 +347,8 @@ void ...@@ -347,8 +347,8 @@ void
Router::initFromDescription(const Rest::Description& desc) { Router::initFromDescription(const Rest::Description& desc) {
auto paths = desc.rawPaths(); auto paths = desc.rawPaths();
for (auto it = paths.flatBegin(), end = paths.flatEnd(); it != end; ++it) { for (auto it = paths.flatBegin(), end = paths.flatEnd(); it != end; ++it) {
const auto& paths = *it; const auto& paths_ = *it;
for (const auto& path: paths) { for (const auto& path: paths_) {
if (!path.isBound()) { if (!path.isBound()) {
std::ostringstream oss; std::ostringstream oss;
oss << "Path '" << path.value << "' is not bound"; oss << "Path '" << path.value << "' is not bound";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment