Commit e12f1c1c authored by Dennis Jenkins's avatar Dennis Jenkins

Initialize class members (-Weffc++ findings).

parent dfa55ba9
......@@ -138,6 +138,12 @@ private:
class ConnectionPool {
public:
ConnectionPool()
: connsLock()
, conns()
, maxConnectionsPerHost()
{ }
void init(size_t maxConnsPerHost);
std::shared_ptr<Connection> pickConnection(const std::string& domain);
......
......@@ -118,7 +118,9 @@ class Allow : public Header {
public:
NAME("Allow");
Allow() { }
Allow()
: methods_()
{ }
explicit Allow(const std::vector<Http::Method>& methods)
: methods_(methods)
......@@ -128,6 +130,7 @@ public:
{ }
explicit Allow(Http::Method method)
: methods_()
{
methods_.push_back(method);
}
......@@ -149,7 +152,9 @@ class Accept : public Header {
public:
NAME("Accept")
Accept() { }
Accept()
: mediaRange_()
{ }
void parseRaw(const char *str, size_t len);
void write(std::ostream& os) const;
......@@ -164,7 +169,9 @@ class AccessControlAllowOrigin : public Header {
public:
NAME("Access-Control-Allow-Origin")
AccessControlAllowOrigin() { }
AccessControlAllowOrigin()
: uri_()
{ }
explicit AccessControlAllowOrigin(const char* uri)
: uri_(uri)
......@@ -190,7 +197,9 @@ class AccessControlAllowHeaders : public Header {
public:
NAME("Access-Control-Allow-Headers")
AccessControlAllowHeaders() { }
AccessControlAllowHeaders()
: val_()
{ }
explicit AccessControlAllowHeaders(const char* val)
: val_(val)
......@@ -216,7 +225,10 @@ class CacheControl : public Header {
public:
NAME("Cache-Control")
CacheControl() { }
CacheControl()
: directives_()
{ }
explicit CacheControl(const std::vector<Http::CacheDirective>& directives)
: directives_(directives)
{ }
......@@ -258,6 +270,10 @@ private:
class EncodingHeader : public Header {
public:
EncodingHeader()
: encoding_()
{ }
void parseRaw(const char* str, size_t len);
void write(std::ostream& os) const;
......@@ -325,10 +341,12 @@ class ContentType : public Header {
public:
NAME("Content-Type")
ContentType() { }
ContentType()
: mime_()
{ }
explicit ContentType(const Mime::MediaType& mime) :
mime_(mime)
explicit ContentType(const Mime::MediaType& mime)
: mime_(mime)
{ }
void parseRaw(const char* str, size_t len);
......@@ -346,10 +364,12 @@ class Date : public Header {
public:
NAME("Date")
Date() { }
Date()
: fullDate_()
{ }
explicit Date(const FullDate& date) :
fullDate_(date)
explicit Date(const FullDate& date)
: fullDate_(date)
{ }
void parse(const std::string &str);
......@@ -365,10 +385,12 @@ class Expect : public Header {
public:
NAME("Expect")
Expect() { }
Expect()
: expectation_()
{ }
explicit Expect(Http::Expectation expectation) :
expectation_(expectation)
explicit Expect(Http::Expectation expectation)
: expectation_(expectation)
{ }
void parseRaw(const char* str, size_t len);
......@@ -385,6 +407,8 @@ public:
NAME("Host");
Host()
: host_()
, port_(0)
{ }
explicit Host(const std::string& host);
......@@ -408,7 +432,9 @@ class Location : public Header {
public:
NAME("Location")
Location() { }
Location()
: location_()
{ }
explicit Location(const std::string& location);
......@@ -425,7 +451,9 @@ class Server : public Header {
public:
NAME("Server")
Server() { }
Server()
: tokens_()
{ }
explicit Server(const std::vector<std::string>& tokens);
explicit Server(const std::string& token);
......@@ -443,7 +471,10 @@ class UserAgent : public Header {
public:
NAME("User-Agent")
UserAgent() { }
UserAgent()
: ua_()
{ }
explicit UserAgent(const char* ua)
: ua_(ua)
{ }
......
......@@ -341,7 +341,11 @@ public:
dequeueIndex.store(other.enqueueIndex.load(), std::memory_order_relaxed);
}
MPMCQueue() {
MPMCQueue()
: cells_()
, enqueueIndex()
, dequeueIndex()
{
for (size_t i = 0; i < Size; ++i) {
cells_[i].sequence.store(i, std::memory_order_relaxed);
}
......@@ -400,6 +404,10 @@ public:
private:
struct Cell {
Cell()
: sequence()
, data()
{ }
std::atomic<size_t> sequence;
T data;
};
......
......@@ -89,6 +89,7 @@ public:
typedef uint16_t Type;
explicit Q(Type val)
: val_()
{
if (val > 100) {
throw std::runtime_error("Invalid quality value, must be in the [0; 100] range");
......@@ -123,12 +124,22 @@ public:
: top_(Type::None)
, sub_(Subtype::None)
, suffix_(Suffix::None)
, raw_()
, rawSubIndex()
, rawSuffixIndex()
, params()
, q_()
{ }
MediaType(std::string raw, Parse parse = DontParse)
: top_(Type::None)
, sub_(Subtype::None)
, suffix_(Suffix::None)
, raw_()
, rawSubIndex()
, rawSuffixIndex()
, params()
, q_()
{
if (parse == DoParse) {
parseRaw(raw.c_str(), raw.length());
......@@ -142,12 +153,22 @@ public:
: top_(top)
, sub_(sub)
, suffix_(Suffix::None)
, raw_()
, rawSubIndex()
, rawSuffixIndex()
, params()
, q_()
{ }
MediaType(Mime::Type top, Mime::Subtype sub, Mime::Suffix suffix)
: top_(top)
, sub_(sub)
, suffix_(suffix)
, raw_()
, rawSubIndex()
, rawSuffixIndex()
, params()
, q_()
{ }
......
......@@ -29,6 +29,7 @@ namespace Aio {
class FdSet {
public:
FdSet(std::vector<Polling::Event>&& events)
: events_()
{
events_.reserve(events.size());
for (auto &&event: events) {
......@@ -163,11 +164,13 @@ private:
class ExecutionContext {
public:
virtual ~ExecutionContext() {}
virtual Reactor::Impl* makeImpl(Reactor* reactor) const = 0;
};
class SyncContext : public ExecutionContext {
public:
virtual ~SyncContext() {}
Reactor::Impl* makeImpl(Reactor* reactor) const override;
};
......@@ -177,6 +180,8 @@ public:
: threads_(threads)
{ }
virtual ~AsyncContext() {}
Reactor::Impl* makeImpl(Reactor* reactor) const override;
static AsyncContext singleThreaded();
......@@ -200,6 +205,10 @@ public:
struct Context {
friend class SyncImpl;
Context()
: tid()
{ }
std::thread::id thread() const { return tid; }
private:
......
......@@ -758,9 +758,13 @@ Client::Options::maxConnectionsPerHost(int val) {
Client::Client()
: reactor_(Aio::Reactor::create())
, pool()
, transport_()
, transportKey()
, ioIndex(0)
{
}
, queuesLock()
, requestsQueues()
{ }
Client::~Client() {
}
......
......@@ -41,11 +41,15 @@ namespace {
} // anonymous namespace
CacheDirective::CacheDirective(Directive directive)
: directive_()
, data()
{
init(directive, std::chrono::seconds(0));
}
CacheDirective::CacheDirective(Directive directive, std::chrono::seconds delta)
: directive_()
, data()
{
init(directive, delta);
}
......
......@@ -331,7 +331,10 @@ Expect::write(std::ostream& os) const {
}
}
Host::Host(const std::string& data) {
Host::Host(const std::string& data)
: host_()
, port_(0)
{
parse(data);
}
......@@ -474,11 +477,13 @@ Server::Server(const std::vector<std::string>& tokens)
{ }
Server::Server(const std::string& token)
: tokens_()
{
tokens_.push_back(token);
}
Server::Server(const char* token)
: tokens_()
{
tokens_.emplace_back(token);
}
......
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