Unverified Commit deb294e6 authored by Kip's avatar Kip Committed by GitHub

Merge pull request #933 from Tachi107/fixing-warnings

Fix some compiler and clang-tidy warnings
parents 01c447af 9e6846e0
......@@ -52,7 +52,7 @@ namespace Pistache::Async
{
public:
const char* what() const noexcept override { return "Bad any cast"; }
virtual ~BadAnyCast() { }
~BadAnyCast() override = default;
};
enum class State { Pending,
......@@ -65,7 +65,7 @@ namespace Pistache::Async
class PromiseBase
{
public:
virtual ~PromiseBase() { }
virtual ~PromiseBase() = default;
virtual bool isPending() const = 0;
virtual bool isFulfilled() const = 0;
virtual bool isRejected() const = 0;
......@@ -192,7 +192,7 @@ namespace Pistache::Async
public:
virtual void resolve(const std::shared_ptr<Core>& core) = 0;
virtual void reject(const std::shared_ptr<Core>& core) = 0;
virtual ~Request() { }
virtual ~Request() = default;
};
struct Core
......@@ -253,7 +253,7 @@ namespace Pistache::Async
state = State::Fulfilled;
}
virtual ~Core() { }
virtual ~Core() = default;
};
template <typename T>
......@@ -264,7 +264,7 @@ namespace Pistache::Async
, storage()
{ }
~CoreT()
~CoreT() override
{
if (allocated)
{
......@@ -342,7 +342,7 @@ namespace Pistache::Async
}
catch (const InternalRethrow& e)
{
chain_->exc = std::move(e.exc);
chain_->exc = e.exc;
chain_->state = State::Rejected;
for (const auto& req : chain_->requests)
{
......@@ -359,7 +359,7 @@ namespace Pistache::Async
virtual void doResolve(const std::shared_ptr<CoreT<T>>& core) = 0;
virtual void doReject(const std::shared_ptr<CoreT<T>>& core) = 0;
virtual ~Continuable() { }
~Continuable() override = default;
size_t resolveCount_;
size_t rejectCount_;
......@@ -464,12 +464,12 @@ namespace Pistache::Async
static_assert(sizeof...(Args) == 0,
"Can not attach a non-void continuation to a void-Promise");
void doResolve(const std::shared_ptr<CoreT<void>>& /*core*/)
void doResolve(const std::shared_ptr<CoreT<void>>& /*core*/) override
{
finishResolve(resolve_());
}
void doReject(const std::shared_ptr<CoreT<void>>& core)
void doReject(const std::shared_ptr<CoreT<void>>& core) override
{
reject_(core->exc);
for (const auto& req : this->chain_->requests)
......@@ -659,13 +659,13 @@ namespace Pistache::Async
, reject_(reject)
{ }
void doResolve(const std::shared_ptr<CoreT<void>>& /*core*/)
void doResolve(const std::shared_ptr<CoreT<void>>& /*core*/) override
{
auto promise = resolve_();
finishResolve(promise);
}
void doReject(const std::shared_ptr<CoreT<void>>& core)
void doReject(const std::shared_ptr<CoreT<void>>& core) override
{
reject_(core->exc);
for (const auto& req : core->requests)
......@@ -1059,7 +1059,7 @@ namespace Pistache::Async
Promise(Promise<T>&& other) = default;
Promise& operator=(Promise<T>&& other) = default;
virtual ~Promise() { }
~Promise() override = default;
template <typename U>
static Promise<T> resolved(U&& value)
......
......@@ -69,6 +69,3 @@ struct PrintException
};
#define unreachable() __builtin_unreachable()
// Until we require C++17 compiler with [[maybe_unused]]
#define UNUSED(x) (void)(x);
......@@ -175,7 +175,7 @@ namespace Pistache::Rest
virtual bool validate(const std::string& input) const = 0;
virtual ~DataType() { }
virtual ~DataType() = default;
};
template <typename T>
......@@ -195,7 +195,7 @@ namespace Pistache::Rest
return Traits::DataTypeValidation<T>::validate(input);
}
virtual ~DataTypeT() { }
~DataTypeT() override = default;
};
template <typename T>
......@@ -357,7 +357,7 @@ namespace Pistache::Rest
PathBuilder& response(Http::Code statusCode, std::string description)
{
path_->responses.push_back(Response(statusCode, std::move(description)));
path_->responses.emplace_back(statusCode, std::move(description));
return *this;
}
......@@ -419,7 +419,7 @@ namespace Pistache::Rest
std::string description = "");
PathBuilder route(PathDecl fragment, std::string description = "");
SubPath path(const std::string& prefix);
SubPath path(const std::string& prefix) const;
template <typename T>
void parameter(std::string name, std::string description)
......
......@@ -162,7 +162,7 @@ namespace Pistache::Http
* [1] https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_verify.html
*/
void useSSLAuth(std::string ca_file, std::string ca_path = "",
int (*cb)(int, void*) = NULL);
int (*cb)(int, void*) = nullptr);
bool isBound() const { return listener.isBound(); }
......
......@@ -21,4 +21,4 @@ namespace Pistache::Tcp
{ }
};
} // namespace Pistache::Tcp
\ No newline at end of file
} // namespace Pistache::Tcp
......@@ -394,6 +394,7 @@ namespace Pistache
// C++11: std::weak_ptr move constructor is C++14 only so the default
// version of move constructor / assignement operator does not work and we
// have to define it ourself
// We're now using C++17, should this be removed?
ResponseWriter(ResponseWriter&& other);
ResponseWriter& operator=(ResponseWriter&& other) = default;
......@@ -701,7 +702,7 @@ namespace Pistache
static std::shared_ptr<RequestParser> getParser(const std::shared_ptr<Tcp::Peer>& peer);
virtual ~Handler() override { }
~Handler() override = default;
private:
void onConnection(const std::shared_ptr<Tcp::Peer>& peer) override;
......
......@@ -229,7 +229,7 @@ namespace Pistache::Http
HttpError(Code code, std::string reason);
HttpError(int code, std::string reason);
~HttpError() noexcept { }
~HttpError() noexcept override = default;
const char* what() const noexcept override { return reason_.c_str(); }
......
......@@ -69,7 +69,7 @@ namespace Pistache::Http::Header
class Header
{
public:
virtual ~Header() { }
virtual ~Header() = default;
virtual const char* name() const = 0;
virtual void parse(const std::string& data);
......@@ -494,7 +494,7 @@ namespace Pistache::Http::Header
: fullDate_(date)
{ }
void parse(const std::string& data) override;
void parse(const std::string& str) override;
void write(std::ostream& os) const override;
FullDate fullDate() const { return fullDate_; }
......@@ -535,7 +535,7 @@ namespace Pistache::Http::Header
, port_(0)
{ }
explicit Host(const std::string& host);
explicit Host(const std::string& data);
explicit Host(const std::string& host, Port port)
: host_(host)
, port_(port)
......@@ -585,7 +585,7 @@ namespace Pistache::Http::Header
explicit Server(const std::string& token);
explicit Server(const char* token);
void parse(const std::string& data) override;
void parse(const std::string& token) override;
void write(std::ostream& os) const override;
std::vector<std::string> tokens() const { return tokens_; }
......
......@@ -29,7 +29,7 @@ namespace Pistache
public:
Mailbox() { data.store(nullptr); }
virtual ~Mailbox() { }
virtual ~Mailbox() = default;
const T* get() const
{
......@@ -269,7 +269,7 @@ namespace Pistache
: event_fd(-1)
{ }
~PollableQueue()
~PollableQueue() override
{
if (event_fd != -1)
close(event_fd);
......
......@@ -17,7 +17,7 @@ namespace Pistache
struct Prototype
{
public:
virtual ~Prototype() { }
virtual ~Prototype() = default;
virtual std::shared_ptr<Class> clone() const = 0;
};
......
......@@ -142,14 +142,14 @@ namespace Pistache::Aio
class ExecutionContext
{
public:
virtual ~ExecutionContext() { }
virtual ~ExecutionContext() = default;
virtual Reactor::Impl* makeImpl(Reactor* reactor) const = 0;
};
class SyncContext : public ExecutionContext
{
public:
virtual ~SyncContext() { }
~SyncContext() override = default;
Reactor::Impl* makeImpl(Reactor* reactor) const override;
};
......@@ -161,7 +161,7 @@ namespace Pistache::Aio
, threadsName_(threadsName)
{ }
virtual ~AsyncContext() { }
~AsyncContext() override = default;
Reactor::Impl* makeImpl(Reactor* reactor) const override;
......@@ -208,7 +208,7 @@ namespace Pistache::Aio
Reactor::Key key() const { return key_; };
virtual ~Handler() { }
~Handler() override = default;
private:
Reactor* reactor_;
......
......@@ -11,7 +11,7 @@ namespace Pistache::ssl
struct SSLCtxDeleter
{
void operator()(void* ptr)
void operator()([[maybe_unused]] void* ptr)
{
#ifdef PISTACHE_USE_SSL
SSL_CTX_free(reinterpret_cast<SSL_CTX*>(ptr));
......@@ -22,20 +22,16 @@ namespace Pistache::ssl
// https://www.openssl.org/news/changelog.txt):
// "Make various cleanup routines no-ops and mark them as deprecated."
EVP_cleanup();
#else
(void)ptr;
#endif
}
};
struct SSLBioDeleter
{
void operator()(void* ptr)
void operator()([[maybe_unused]] void* ptr)
{
#ifdef PISTACHE_USE_SSL
BIO_free(reinterpret_cast<BIO*>(ptr));
#else
(void)ptr;
#endif
}
};
......
......@@ -28,7 +28,7 @@ namespace Pistache::Log
virtual void log(Level level, const std::string& message) = 0;
virtual bool isEnabledFor(Level level) const = 0;
virtual ~StringLogger() { }
virtual ~StringLogger() = default;
};
class StringToStreamLogger : public StringLogger
......@@ -38,7 +38,7 @@ namespace Pistache::Log
: level_(level)
, out_(out)
{ }
~StringToStreamLogger() override { }
~StringToStreamLogger() override = default;
void log(Level level, const std::string& message) override;
bool isEnabledFor(Level level) const override;
......
......@@ -38,7 +38,7 @@ namespace Pistache::Tcp
friend class Transport;
Handler();
virtual ~Handler();
~Handler() override;
virtual void onInput(const char* buffer, size_t len,
const std::shared_ptr<Tcp::Peer>& peer)
......
......@@ -34,10 +34,10 @@ namespace Pistache::Tcp
void init(const std::shared_ptr<Tcp::Handler>& handler);
virtual void registerPoller(Polling::Epoll& poller) override;
void registerPoller(Polling::Epoll& poller) override;
void handleNewPeer(const std::shared_ptr<Peer>& peer);
virtual void onReady(const Aio::FdSet& fds) override;
void onReady(const Aio::FdSet& fds) override;
template <typename Buf>
Async::Promise<ssize_t> asyncWrite(Fd fd, const Buf& buffer, int flags = 0)
......@@ -178,7 +178,7 @@ namespace Pistache::Tcp
void disable() { active.store(false, std::memory_order_relaxed); }
bool isActive() { return active.load(std::memory_order_relaxed); }
bool isActive() const { return active.load(std::memory_order_relaxed); }
Fd fd;
std::chrono::milliseconds value;
......@@ -241,7 +241,7 @@ namespace Pistache::Tcp
void handlePeerQueue();
void handleNotify();
void handleTimer(TimerEntry entry);
void handlePeer(const std::shared_ptr<Peer>& entry);
void handlePeer(const std::shared_ptr<Peer>& peer);
};
} // namespace Pistache::Tcp
......@@ -5,4 +5,4 @@ namespace Pistache
#define REQUIRES(condition) typename std::enable_if<(condition), int>::type = 0
} // namespace Pistache
\ No newline at end of file
} // namespace Pistache
......@@ -17,7 +17,7 @@ compiler = meson.get_compiler('cpp')
# Wrapping arguments inside a call to get_supported_arguments so that only supported arguments get applied
# No need for -Wall -Wextra -Wpedantic, since warning_level is 3
add_project_arguments(compiler.get_supported_arguments(['-Wconversion', '-Wno-missing-field-initializers']), language: 'cpp')
add_project_arguments(compiler.get_supported_arguments(['-Wconversion', '-Wno-sign-conversion', '-Wno-missing-field-initializers']), language: 'cpp')
# No need for --coverage, since b_coverage is set
if get_option('b_coverage')
......
......@@ -109,10 +109,10 @@ namespace Pistache
{
using Http::crlf;
auto res = request.resource();
auto [host, path] = splitUrl(res);
auto body = request.body();
auto query = request.query();
const auto& res = request.resource();
const auto [host, path] = splitUrl(res);
const auto& body = request.body();
const auto& query = request.query();
auto pathStr = std::string(path);
......@@ -565,7 +565,7 @@ namespace Pistache
.then(
[=]() {
socklen_t len = sizeof(saddr);
getsockname(sfd, (struct sockaddr*)&saddr, &len);
getsockname(sfd, reinterpret_cast<struct sockaddr*>(&saddr), &len);
connectionState_.store(Connected);
processRequestQueue();
},
......@@ -848,15 +848,13 @@ namespace Pistache
[](const std::shared_ptr<Connection>& conn) { return conn->isIdle(); });
}
size_t ConnectionPool::availableConnections(const std::string& domain) const
size_t ConnectionPool::availableConnections(const std::string& /*domain*/) const
{
UNUSED(domain)
return 0;
}
void ConnectionPool::closeIdleConnections(const std::string& domain)
void ConnectionPool::closeIdleConnections(const std::string& /*domain*/)
{
UNUSED(domain)
}
void ConnectionPool::shutdown()
......
......@@ -24,7 +24,7 @@ using namespace std;
vector<byte>::size_type Base64Decoder::CalculateDecodedSize() const
{
// If encoded size was zero, so is decoded size...
if (m_Base64EncodedString.size() == 0)
if (m_Base64EncodedString.empty())
return 0;
// If non-zero, should always be at least four characters...
......
......@@ -76,9 +76,8 @@ namespace Pistache::Http
template <>
struct AttributeMatcher<bool>
{
static void match(StreamCursor& cursor, Cookie* obj, bool Cookie::*attr)
static void match(StreamCursor& /*cursor*/, Cookie* obj, bool Cookie::*attr)
{
UNUSED(cursor)
obj->*attr = true;
}
};
......
......@@ -222,7 +222,7 @@ namespace Pistache::Rest
std::move(description));
}
SubPath SubPath::path(const std::string& prefix)
SubPath SubPath::path(const std::string& prefix) const
{
return SubPath(this->prefix + prefix, paths);
}
......@@ -396,7 +396,7 @@ namespace Pistache::Rest
Route::Handler uiHandler = [=](const Rest::Request& req,
Http::ResponseWriter response) {
auto res = req.resource();
const auto& res = req.resource();
/*
* @Export might be useful for routing also. Make it public or merge it with
......@@ -431,7 +431,7 @@ namespace Pistache::Rest
bool matches(const Rest::Request& req) const
{
auto res_ = req.resource();
const auto& res_ = req.resource();
if (value == res_)
return true;
......@@ -443,11 +443,11 @@ namespace Pistache::Rest
bool isPrefix(const Rest::Request& req)
{
auto res_ = req.resource();
const auto& res_ = req.resource();
return !res_.compare(0, value.size(), value);
}
const std::string& withTrailingSlash() const
[[maybe_unused]] const std::string& withTrailingSlash() const
{
return trailingSlashValue;
}
......
......@@ -14,6 +14,7 @@
#include <ctime>
#include <iomanip>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <unordered_map>
......@@ -137,7 +138,7 @@ namespace Pistache::Http
{
StreamCursor::Revert revert(cursor);
auto request = static_cast<Request*>(message);
auto* request = static_cast<Request*>(message);
StreamCursor::Token methodToken(cursor);
if (!match_until(' ', cursor))
......@@ -872,9 +873,8 @@ namespace Pistache::Http
DynamicStreamBuf* ResponseWriter::rdbuf() { return &buf_; }
DynamicStreamBuf* ResponseWriter::rdbuf(DynamicStreamBuf* other)
DynamicStreamBuf* ResponseWriter::rdbuf(DynamicStreamBuf* /*other*/)
{
UNUSED(other)
throw std::domain_error("Unimplemented");
}
......@@ -1038,9 +1038,9 @@ namespace Pistache::Http
, request()
, time_(std::chrono::steady_clock::now())
{
allSteps[0].reset(new RequestLineStep(&request));
allSteps[1].reset(new HeadersStep(&request));
allSteps[2].reset(new BodyStep(&request));
allSteps[0] = std::make_unique<RequestLineStep>(&request);
allSteps[1] = std::make_unique<HeadersStep>(&request);
allSteps[2] = std::make_unique<BodyStep>(&request);
}
void Private::ParserImpl<Http::Request>::reset()
......@@ -1055,9 +1055,9 @@ namespace Pistache::Http
: ParserBase(maxDataSize)
, response()
{
allSteps[0].reset(new ResponseLineStep(&response));
allSteps[1].reset(new HeadersStep(&response));
allSteps[2].reset(new BodyStep(&response));
allSteps[0] = std::make_unique<ResponseLineStep>(&response);
allSteps[1] = std::make_unique<HeadersStep>(&response);
allSteps[2] = std::make_unique<BodyStep>(&response);
}
void Handler::onInput(const char* buffer, size_t len,
......@@ -1142,16 +1142,15 @@ namespace Pistache::Http
Timeout::Timeout(Tcp::Transport* transport_, Http::Version version, Handler* handler_,
std::weak_ptr<Tcp::Peer> peer_)
: handler(handler_)
, transport(transport_)
, version(version)
, transport(transport_)
, armed(false)
, timerFd(-1)
, peer(peer_)
{ }
void Timeout::onTimeout(uint64_t numWakeup)
void Timeout::onTimeout(uint64_t /*numWakeup*/)
{
UNUSED(numWakeup)
auto sp = peer.lock();
if (!sp)
return;
......
......@@ -20,9 +20,9 @@
namespace Pistache::Http::Header
{
void Header::parse(const std::string& str)
void Header::parse(const std::string& data)
{
parseRaw(str.c_str(), str.length());
parseRaw(data.c_str(), data.length());
}
void Header::parseRaw(const char* str, size_t len)
......@@ -30,10 +30,8 @@ namespace Pistache::Http::Header
parse(std::string(str, len));
}
void Allow::parseRaw(const char* str, size_t len)
void Allow::parseRaw(const char* /*str*/, size_t /*len*/)
{
UNUSED(str)
UNUSED(len)
}
const char* encodingString(Encoding encoding)
......@@ -136,7 +134,7 @@ namespace Pistache::Http::Header
{
if (match_raw(d.str, d.size, cursor))
{
directives_.push_back(CacheDirective(d.repr));
directives_.emplace_back(d.repr);
found = true;
break;
}
......@@ -167,8 +165,7 @@ namespace Pistache::Http::Header
throw std::runtime_error(
"Invalid caching directive, malformated delta-seconds");
}
directives_.push_back(
CacheDirective(d.repr, std::chrono::seconds(secs)));
directives_.emplace_back(d.repr, std::chrono::seconds(secs));
break;
}
}
......@@ -322,7 +319,7 @@ namespace Pistache::Http::Header
value_ = val;
}
catch (const std::invalid_argument& e)
catch (const std::invalid_argument& /*e*/)
{
}
}
......@@ -571,7 +568,7 @@ namespace Pistache::Http::Header
} while (!cursor.eof());
}
void Accept::write(std::ostream& os) const { UNUSED(os) }
void Accept::write(std::ostream& /*os*/) const {}
void AccessControlAllowOrigin::parse(const std::string& data) { uri_ = data; }
......@@ -644,7 +641,7 @@ namespace Pistache::Http::Header
{
for (size_t i = 0; i < tokens_.size(); i++)
{
auto& token = tokens_[i];
const auto& token = tokens_[i];
os << token;
if (i < tokens_.size() - 1)
{
......
......@@ -55,9 +55,9 @@ namespace Pistache::Http::Header
return instance;
}
Registry::Registry() { }
Registry::Registry() = default;
Registry::~Registry() { }
Registry::~Registry() = default;
void Registry::registerHeader(const std::string& name,
Registry::RegistryFunc func)
......
......@@ -133,7 +133,7 @@ namespace Pistache::Http::Mime
MIME_TYPES
#undef TYPE
raise("Unknown Media Type");
} while (0);
} while (false);
top_ = top;
......@@ -165,7 +165,7 @@ namespace Pistache::Http::Mime
MIME_SUBTYPES
#undef SUB_TYPE
sub = Subtype::Ext;
} while (0);
} while (false);
}
if (sub == Subtype::Ext || sub == Subtype::Vendor)
......@@ -201,7 +201,7 @@ namespace Pistache::Http::Mime
MIME_SUFFIXES
#undef SUFFIX
suffix = Suffix::Ext;
} while (0);
} while (false);
if (suffix == Suffix::Ext)
{
......
......@@ -129,7 +129,7 @@ namespace Pistache
{
if (data.empty())
throw std::invalid_argument("Invalid port: empty port");
char* end = 0;
char* end = nullptr;
long port_num = strtol(data.c_str(), &end, 10);
if (*end != 0 || port_num < Port::min() || port_num > Port::max())
throw std::invalid_argument("Invalid port: " + data);
......@@ -409,7 +409,7 @@ namespace Pistache
}
else
{
char* end = 0;
char* end = nullptr;
long port = strtol(portPart.c_str(), &end, 10);
if (*end != 0 || port < Port::min() || port > Port::max())
throw std::invalid_argument("Invalid port");
......
......@@ -30,10 +30,7 @@ namespace Pistache
flags |= O_NONBLOCK;
int ret = fcntl(fd, F_SETFL, flags);
if (ret == -1)
return false;
return true;
return ret != -1;
}
CpuSet::CpuSet() { bits.reset(); }
......
......@@ -22,7 +22,7 @@ namespace Pistache::Tcp
struct ConcretePeer : Peer
{
ConcretePeer() = default;
ConcretePeer(Fd fd, const Address& addr, void* ssl)
[[maybe_unused]] ConcretePeer(Fd fd, const Address& addr, void* ssl)
: Peer(fd, addr, ssl)
{ }
};
......@@ -68,13 +68,13 @@ namespace Pistache::Tcp
}
else
{
if (!getnameinfo((struct sockaddr*)&sa, sizeof(sa), host, sizeof(host),
NULL, 0 // Service info
if (!getnameinfo(reinterpret_cast<struct sockaddr*>(&sa), sizeof(sa), host, sizeof(host),
nullptr, 0 // Service info
,
NI_NAMEREQD // Raise an error if name resolution failed
))
{
hostname_.assign((char*)host);
hostname_.assign(static_cast<char*>(host));
}
}
}
......@@ -116,7 +116,7 @@ namespace Pistache::Tcp
return data;
}
std::shared_ptr<void> Peer::tryGetData(std::string(name)) const
std::shared_ptr<void> Peer::tryGetData(std::string name) const
{
auto it = data_.find(name);
if (it == std::end(data_))
......
......@@ -131,7 +131,7 @@ namespace Pistache::Aio
poller.rearmFd(fd, Flags<Polling::NotifyOn>(interest), pollTag, mode);
}
void removeFd(const Reactor::Key& key, Fd fd) override
void removeFd(const Reactor::Key& /*key*/, Fd fd) override
{
poller.removeFd(fd);
}
......@@ -402,7 +402,7 @@ namespace Pistache::Aio
std::vector<std::shared_ptr<Handler>> res;
res.reserve(workers_.size());
for (auto& wrk : workers_)
for (const auto& wrk : workers_)
{
res.push_back(wrk->sync->handler(originalKey));
}
......@@ -474,7 +474,7 @@ namespace Pistache::Aio
void dispatchCall(const Reactor::Key& key, Func func, Args&&... args) const
{
auto decoded = decodeKey(key);
auto& wrk = workers_.at(decoded.second);
const auto& wrk = workers_.at(decoded.second);
Reactor::Key originalKey(decoded.first);
CALL_MEMBER_FN(wrk->sync.get(), func)
......@@ -501,7 +501,7 @@ namespace Pistache::Aio
void run()
{
thread = std::thread([=]() {
if (threadsName_.size() > 0)
if (!threadsName_.empty())
{
pthread_setname_np(pthread_self(),
threadsName_.substr(0, 15).c_str());
......
......@@ -93,7 +93,7 @@ namespace Pistache
DynamicStreamBuf::DynamicStreamBuf(DynamicStreamBuf&& other)
: data_(std::move(other.data_))
, maxSize_(std::move(other.maxSize_))
, maxSize_(other.maxSize_)
{
setp(other.pptr(), other.epptr());
other.setp(nullptr, nullptr);
......@@ -104,7 +104,7 @@ namespace Pistache
if (&other != this)
{
data_ = std::move(other.data_);
maxSize_ = std::move(other.maxSize_);
maxSize_ = other.maxSize_;
setp(other.pptr(), other.epptr());
other.setp(nullptr, nullptr);
}
......
......@@ -14,21 +14,17 @@ namespace Pistache::Tcp
: transport_(nullptr)
{ }
Handler::~Handler() { }
Handler::~Handler() = default;
void Handler::associateTransport(Transport* transport)
{
transport_ = transport;
}
void Handler::onConnection(const std::shared_ptr<Tcp::Peer>& peer)
{
UNUSED(peer)
}
void Handler::onConnection(const std::shared_ptr<Tcp::Peer>& /*peer*/)
{ }
void Handler::onDisconnection(const std::shared_ptr<Tcp::Peer>& peer)
{
UNUSED(peer)
}
void Handler::onDisconnection(const std::shared_ptr<Tcp::Peer>& /*peer*/)
{ }
} // namespace Pistache::Tcp
......@@ -53,7 +53,7 @@ namespace Pistache
spec.it_value.tv_sec = 0;
spec.it_value.tv_nsec = 0;
TRY(timerfd_settime(fd_, 0, &spec, 0));
TRY(timerfd_settime(fd_, 0, &spec, nullptr));
}
void TimerPool::Entry::registerReactor(const Aio::Reactor::Key& key,
......@@ -82,7 +82,7 @@ namespace Pistache
spec.it_value.tv_sec = std::chrono::duration_cast<std::chrono::seconds>(value).count();
spec.it_value.tv_nsec = 0;
}
TRY(timerfd_settime(fd_, 0, &spec, 0));
TRY(timerfd_settime(fd_, 0, &spec, nullptr));
}
TimerPool::TimerPool(size_t initialSize)
......
......@@ -239,7 +239,7 @@ namespace Pistache::Tcp
return;
}
auto& wq = it->second;
if (wq.size() == 0)
if (wq.empty())
{
break;
}
......@@ -251,7 +251,7 @@ namespace Pistache::Tcp
auto cleanUp = [&]() {
wq.pop_front();
if (wq.size() == 0)
if (wq.empty())
{
toWrite.erase(fd);
reactor()->modifyFd(key(), fd, NotifyOn::Read, Polling::Mode::Edge);
......@@ -269,7 +269,7 @@ namespace Pistache::Tcp
if (buffer.isRaw())
{
auto raw = buffer.raw();
auto ptr = raw.data().c_str() + totalWritten;
const auto* ptr = raw.data().c_str() + totalWritten;
bytesWritten = sendRawBuffer(fd, ptr, len, flags);
}
else
......@@ -428,7 +428,7 @@ namespace Pistache::Tcp
spec.it_value.tv_nsec = 0;
}
int res = timerfd_settime(entry.fd, 0, &spec, 0);
int res = timerfd_settime(entry.fd, 0, &spec, nullptr);
if (res == -1)
{
entry.deferred.reject(Pistache::Error::system("Could not set timer time"));
......
......@@ -65,7 +65,7 @@ namespace Pistache::Http
spec.it_interval.tv_sec = 0;
spec.it_interval.tv_nsec = TimerIntervalNs.count();
TRY(timerfd_settime(timerFd, 0, &spec, 0));
TRY(timerfd_settime(timerFd, 0, &spec, nullptr));
Polling::Tag tag(timerFd);
poller.addFd(timerFd, Flags<Polling::NotifyOn>(Polling::NotifyOn::Read), Polling::Tag(timerFd));
......@@ -195,7 +195,7 @@ namespace Pistache::Http
return *this;
}
Endpoint::Endpoint() { }
Endpoint::Endpoint() = default;
Endpoint::Endpoint(const Address& addr)
: listener(addr)
......@@ -242,25 +242,19 @@ namespace Pistache::Http
void Endpoint::shutdown() { listener.shutdown(); }
void Endpoint::useSSL(const std::string& cert, const std::string& key, bool use_compression)
void Endpoint::useSSL([[maybe_unused]] const std::string& cert, [[maybe_unused]] const std::string& key, [[maybe_unused]] bool use_compression)
{
#ifndef PISTACHE_USE_SSL
(void)cert;
(void)key;
(void)use_compression;
throw std::runtime_error("Pistache is not compiled with SSL support.");
#else
listener.setupSSL(cert, key, use_compression);
#endif /* PISTACHE_USE_SSL */
}
void Endpoint::useSSLAuth(std::string ca_file, std::string ca_path,
int (*cb)(int, void*))
void Endpoint::useSSLAuth([[maybe_unused]] std::string ca_file, [[maybe_unused]] std::string ca_path,
[[maybe_unused]] int (*cb)(int, void*))
{
#ifndef PISTACHE_USE_SSL
(void)ca_file;
(void)ca_path;
(void)cb;
throw std::runtime_error("Pistache is not compiled with SSL support.");
#else
listener.setupSSLAuth(ca_file, ca_path, cb);
......
......@@ -215,10 +215,8 @@ namespace Pistache::Tcp
handler_ = handler;
}
void Listener::pinWorker(size_t worker, const CpuSet& set)
void Listener::pinWorker([[maybe_unused]] size_t worker, [[maybe_unused]] const CpuSet& set)
{
UNUSED(worker)
UNUSED(set)
#if 0
if (ioGroup.empty()) {
throw std::domain_error("Invalid operation, did you call init() before ?");
......@@ -314,7 +312,7 @@ namespace Pistache::Tcp
struct sockaddr_in sock_addr = { 0 };
socklen_t addrlen = sizeof(sock_addr);
auto sock_addr_alias = reinterpret_cast<struct sockaddr*>(&sock_addr);
auto* sock_addr_alias = reinterpret_cast<struct sockaddr*>(&sock_addr);
if (-1 == getsockname(listen_fd, sock_addr_alias, &addrlen))
{
......@@ -498,7 +496,7 @@ namespace Pistache::Tcp
socklen_t peer_addr_len = sizeof(peer_addr);
// Do not share open FD with forked processes
int client_fd = ::accept4(
listen_fd, (struct sockaddr*)&peer_addr, &peer_addr_len, SOCK_CLOEXEC);
listen_fd, reinterpret_cast<struct sockaddr*>(&peer_addr), &peer_addr_len, SOCK_CLOEXEC);
if (client_fd < 0)
{
if (errno == EBADF || errno == ENOTSOCK)
......
......@@ -388,7 +388,7 @@ namespace Pistache::Rest
void Router::initFromDescription(const Rest::Description& desc)
{
auto paths = desc.rawPaths();
const auto& paths = desc.rawPaths();
for (auto it = paths.flatBegin(), end = paths.flatEnd(); it != end; ++it)
{
const auto& paths_ = *it;
......@@ -479,14 +479,14 @@ namespace Pistache::Rest
std::move(resp));
}
Route::Status Router::route(const Http::Request& http_req,
Route::Status Router::route(const Http::Request& request,
Http::ResponseWriter response)
{
const auto resource = http_req.resource();
const auto& resource = request.resource();
if (resource.empty())
throw std::runtime_error("Invalid zero-length URL.");
auto req = http_req;
auto req = request;
auto resp = response.clone();
for (const auto& middleware : middlewares)
......
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