summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2022-01-03 18:34:16 +0000
committerSadie Powell <sadie@witchery.services>2022-01-04 00:17:13 +0000
commit7531e90499d4cd60b6464c692725225e85c00738 (patch)
tree930fd946ea495b74c4071a67e12cadb700ab79ab /include
parentdfcc025a19d7d49179d75f34553c36e0d47eaded (diff)
Use C++11 style class/struct initialisation.
Diffstat (limited to 'include')
-rw-r--r--include/account.h4
-rw-r--r--include/anope.h2
-rw-r--r--include/base.h13
-rw-r--r--include/commands.h6
-rw-r--r--include/config.h2
-rw-r--r--include/lists.h4
-rw-r--r--include/logger.h22
-rw-r--r--include/mail.h2
-rw-r--r--include/memo.h2
-rw-r--r--include/modes.h4
-rw-r--r--include/modules/dns.h16
-rw-r--r--include/modules/httpd.h6
-rw-r--r--include/modules/os_forbid.h6
-rw-r--r--include/modules/os_ignore.h4
-rw-r--r--include/modules/os_session.h6
-rw-r--r--include/modules/sql.h4
-rw-r--r--include/opertype.h2
-rw-r--r--include/protocol.h6
-rw-r--r--include/serialize.h20
-rw-r--r--include/servers.h2
-rw-r--r--include/threadengine.h6
-rw-r--r--include/xline.h4
22 files changed, 66 insertions, 77 deletions
diff --git a/include/account.h b/include/account.h
index 163d7d0c6..92b892f65 100644
--- a/include/account.h
+++ b/include/account.h
@@ -240,8 +240,8 @@ class CoreExport IdentifyRequest
Anope::string password;
std::set<Module *> holds;
- bool dispatched;
- bool success;
+ bool dispatched = false;
+ bool success = false;
static std::set<IdentifyRequest *> Requests;
diff --git a/include/anope.h b/include/anope.h
index d998ce1a9..96967bfb8 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -559,7 +559,7 @@ class CoreExport sepstream
char sep;
/** Current string position
*/
- size_t pos;
+ size_t pos = 0;
/** If set then GetToken() can return an empty string
*/
bool allow_empty;
diff --git a/include/base.h b/include/base.h
index 09ec83edf..408f8dd16 100644
--- a/include/base.h
+++ b/include/base.h
@@ -16,9 +16,8 @@
class CoreExport Base
{
/* References to this base class */
- std::set<ReferenceBase *> *references;
+ std::set<ReferenceBase *> *references = nullptr;
public:
- Base();
virtual ~Base();
/** Adds a reference to this object. Eg, when a Reference
@@ -33,9 +32,9 @@ class CoreExport Base
class ReferenceBase
{
protected:
- bool invalid;
+ bool invalid = false;
public:
- ReferenceBase() : invalid(false) { }
+ ReferenceBase() = default;
ReferenceBase(const ReferenceBase &other) : invalid(other.invalid) { }
virtual ~ReferenceBase() { }
inline void Invalidate() { this->invalid = true; }
@@ -48,11 +47,9 @@ template<typename T>
class Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
diff --git a/include/commands.h b/include/commands.h
index 64335720f..29fa3a601 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -26,8 +26,6 @@ struct CommandInfo
{
typedef Anope::map<CommandInfo> map;
- CommandInfo() : hide(false), prepend_channel(false) { }
-
/* Service name of the command */
Anope::string name;
/* Permission required to execute the command */
@@ -35,9 +33,9 @@ struct CommandInfo
/* Group this command is in */
Anope::string group;
/* whether or not to hide this command in help output */
- bool hide;
+ bool hide = false;
/* Only used with fantasy */
- bool prepend_channel;
+ bool prepend_channel = false;
};
/* Where the replies from commands go to. User inherits from this and is the normal
diff --git a/include/config.h b/include/config.h
index 82c1ad5c8..b59b5ad69 100644
--- a/include/config.h
+++ b/include/config.h
@@ -73,7 +73,7 @@ namespace Configuration
{
Anope::string name;
bool executable;
- FILE *fp;
+ FILE *fp = nullptr;
public:
File(const Anope::string &, bool);
~File();
diff --git a/include/lists.h b/include/lists.h
index 7a3f744c6..baff1a20b 100644
--- a/include/lists.h
+++ b/include/lists.h
@@ -25,7 +25,7 @@
class CoreExport NumberList
{
private:
- bool is_valid;
+ bool is_valid = true;
std::set<unsigned> numbers;
@@ -83,7 +83,7 @@ class CoreExport InfoFormatter
{
NickCore *nc;
std::vector<std::pair<Anope::string, Anope::string> > replies;
- unsigned longest;
+ unsigned longest = 0;
public:
InfoFormatter(NickCore *nc);
void Process(std::vector<Anope::string> &);
diff --git a/include/logger.h b/include/logger.h
index 51868d917..98e1bc156 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -53,23 +53,23 @@ class CoreExport Log
{
public:
/* Bot that should log this message */
- BotInfo *bi;
+ BotInfo *bi = nullptr;
/* For commands, the user executing the command, but might not always exist */
- User *u;
+ User *u = nullptr;
/* For commands, the account executing the command, but will not always exist */
- NickCore *nc;
+ NickCore *nc = nullptr;
/* For commands, the command being executed */
- Command *c;
+ Command *c = nullptr;
/* For commands, the command source */
- CommandSource *source;
+ CommandSource *source = nullptr;
/* Used for LOG_CHANNEL */
- Channel *chan;
+ Channel *chan = nullptr;
/* For commands, the channel the command was executed on, will not always exist */
- const ChannelInfo *ci;
+ const ChannelInfo *ci = nullptr;
/* For LOG_SERVER */
- Server *s;
+ Server *s = nullptr;
/* For LOG_MODULE */
- Module *m;
+ Module *m = nullptr;
LogType type;
Anope::string category;
@@ -113,10 +113,10 @@ class CoreExport Log
class CoreExport LogInfo
{
public:
- BotInfo *bot;
+ BotInfo *bot = nullptr;
std::vector<Anope::string> targets;
std::vector<LogFile *> logfiles;
- int last_day;
+ int last_day = 0;
std::vector<Anope::string> sources;
int log_age;
std::vector<Anope::string> admin;
diff --git a/include/mail.h b/include/mail.h
index 932d1a6e6..65873feba 100644
--- a/include/mail.h
+++ b/include/mail.h
@@ -34,7 +34,7 @@ namespace Mail
Anope::string message;
bool dont_quote_addresses;
- bool success;
+ bool success = false;
public:
/** Construct this message. Once constructed call Thread::Start to launch the mail sending.
* @param sf Config->SendFrom
diff --git a/include/memo.h b/include/memo.h
index 112fd3c21..a41730b53 100644
--- a/include/memo.h
+++ b/include/memo.h
@@ -39,7 +39,7 @@ class CoreExport Memo : public Serializable
*/
struct CoreExport MemoInfo
{
- int16_t memomax;
+ int16_t memomax = 0;
Serialize::Checker<std::vector<Memo *> > memos;
std::vector<Anope::string> ignores;
diff --git a/include/modes.h b/include/modes.h
index cbde11429..3b4b0c1bb 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -394,8 +394,8 @@ class CoreExport Entry
Anope::string name;
Anope::string mask;
public:
- unsigned short cidr_len;
- int family;
+ unsigned short cidr_len = 0;
+ int family = 0;
Anope::string nick, user, host, real;
/** Constructor
diff --git a/include/modules/dns.h b/include/modules/dns.h
index 1fe642c3b..afbac2944 100644
--- a/include/modules/dns.h
+++ b/include/modules/dns.h
@@ -73,10 +73,10 @@ namespace DNS
struct Question
{
Anope::string name;
- QueryType type;
- unsigned short qclass;
+ QueryType type = QUERY_NONE;
+ unsigned short qclass = 0;
- Question() : type(QUERY_NONE), qclass(0) { }
+ Question() = default;
Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { }
inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; }
@@ -91,12 +91,12 @@ namespace DNS
struct ResourceRecord : Question
{
- unsigned int ttl;
+ unsigned int ttl = 0;
Anope::string rdata;
time_t created;
- ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { }
- ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { }
+ ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), created(Anope::CurTime) { }
+ ResourceRecord(const Question &q) : Question(q), created(Anope::CurTime) { }
};
struct Query
@@ -139,12 +139,12 @@ namespace DNS
/* Use result cache if available */
bool use_cache;
/* Request id */
- unsigned short id;
+ unsigned short id = 0;
/* Creator of this request */
Module *creator;
Request(Manager *mgr, Module *c, const Anope::string &addr, QueryType qt, bool cache = false) : Timer(0), Question(addr, qt), manager(mgr),
- use_cache(cache), id(0), creator(c) { }
+ use_cache(cache), creator(c) { }
virtual ~Request()
{
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 6431534e3..d9ab85df7 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -21,13 +21,13 @@ enum HTTPError
/* A message to someone */
struct HTTPReply
{
- HTTPError error;
+ HTTPError error = HTTP_ERROR_OK;
Anope::string content_type;
std::map<Anope::string, Anope::string, ci::less> headers;
typedef std::list<std::pair<Anope::string, Anope::string> > cookie;
std::vector<cookie> cookies;
- HTTPReply() : error(HTTP_ERROR_OK), length(0) { }
+ HTTPReply() = default;
HTTPReply(const HTTPReply& other) : error(other.error), length(other.length)
{
@@ -65,7 +65,7 @@ struct HTTPReply
};
std::deque<Data *> out;
- size_t length;
+ size_t length = 0;
void Write(const Anope::string &message)
{
diff --git a/include/modules/os_forbid.h b/include/modules/os_forbid.h
index 3ae9b7551..140731593 100644
--- a/include/modules/os_forbid.h
+++ b/include/modules/os_forbid.h
@@ -23,13 +23,13 @@ struct ForbidData
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
ForbidType type;
virtual ~ForbidData() { }
protected:
- ForbidData() : created(0), expires(0) { }
+ ForbidData() = default;
};
class ForbidService : public Service
diff --git a/include/modules/os_ignore.h b/include/modules/os_ignore.h
index 69596c4bb..55eb96554 100644
--- a/include/modules/os_ignore.h
+++ b/include/modules/os_ignore.h
@@ -14,11 +14,11 @@ struct IgnoreData
Anope::string mask;
Anope::string creator;
Anope::string reason;
- time_t time; /* When do we stop ignoring them? */
+ time_t time = 0; /* When do we stop ignoring them? */
virtual ~IgnoreData() { }
protected:
- IgnoreData() : time(0) { }
+ IgnoreData() = default;
};
class IgnoreService : public Service
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index 0dd2cdcb4..8318a40ec 100644
--- a/include/modules/os_session.h
+++ b/include/modules/os_session.h
@@ -12,10 +12,10 @@
struct Session
{
cidr addr; /* A cidr (sockaddrs + len) representing this session */
- unsigned count; /* Number of clients with this host */
- unsigned hits; /* Number of subsequent kills for a host */
+ unsigned count = 1; /* Number of clients with this host */
+ unsigned hits = 0; /* Number of subsequent kills for a host */
- Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { }
+ Session(const sockaddrs &ip, int len) : addr(ip, len) { }
};
struct Exception : Serializable
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 0be5e93d0..d78f64391 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -141,10 +141,10 @@ namespace SQL
Query query;
Anope::string error;
public:
- unsigned int id;
+ unsigned int id = 0;
Anope::string finished_query;
- Result() : id(0) { }
+ Result() = default;
Result(unsigned int i, const Query &q, const Anope::string &fq, const Anope::string &err = "") : query(q), error(err), id(i), finished_query(fq) { }
inline operator bool() const { return this->error.empty(); }
diff --git a/include/opertype.h b/include/opertype.h
index 58f6049ab..9e46dda5b 100644
--- a/include/opertype.h
+++ b/include/opertype.h
@@ -22,7 +22,7 @@ struct CoreExport Oper
/* The type of operator this operator is */
OperType *ot;
/* Whether the user must be an IRC operator (umode +o) to be considered a services operator */
- bool require_oper;
+ bool require_oper = true;
Anope::string password;
Anope::string certfp;
/* Hosts allowed to use this operator block */
diff --git a/include/protocol.h b/include/protocol.h
index cc3329bf1..6bb649f74 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -246,8 +246,8 @@ class CoreExport IRCDProto : public Service
class CoreExport MessageSource
{
Anope::string source;
- User *u;
- Server *s;
+ User *u = nullptr;
+ Server *s = nullptr;
public:
MessageSource(const Anope::string &);
@@ -289,7 +289,7 @@ private:
Anope::string message;
/** The current position within the message. */
- Anope::string::size_type position;
+ Anope::string::size_type position = 0;
public:
/** Create a tokenstream and fill it with the provided data. */
diff --git a/include/serialize.h b/include/serialize.h
index 406b9698f..a09f30e08 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -65,9 +65,9 @@ class CoreExport Serializable : public virtual Base
/* Iterator into serializable_items */
std::list<Serializable *>::iterator s_iter;
/* The hash of the last serialized form of this object committed to the database */
- size_t last_commit;
+ size_t last_commit = 0;
/* The last time this object was committed to the database */
- time_t last_commit_time;
+ time_t last_commit_time = 0;
protected:
Serializable(const Anope::string &serialize_type);
@@ -79,10 +79,10 @@ class CoreExport Serializable : public virtual Base
virtual ~Serializable();
/* Unique ID (per type, not globally) for this object */
- uint64_t id;
+ uint64_t id = 0;
/* Only used by redis, to ignore updates */
- unsigned short redis_ignore;
+ unsigned short redis_ignore = 0;
/** Marks the object as potentially being updated "soon".
*/
@@ -127,7 +127,7 @@ class CoreExport Serialize::Type : public Base
* this timestamp. if curtime == timestamp then we have the most up to date
* version of every object of this type.
*/
- time_t timestamp;
+ time_t timestamp = 0;
public:
/* Map of Serializable::id to Serializable objects */
@@ -187,7 +187,7 @@ class Serialize::Checker
{
Anope::string name;
T obj;
- mutable ::Reference<Serialize::Type> type;
+ mutable ::Reference<Serialize::Type> type = nullptr;
inline void Check() const
{
@@ -198,7 +198,7 @@ class Serialize::Checker
}
public:
- Checker(const Anope::string &n) : name(n), type(NULL) { }
+ Checker(const Anope::string &n) : name(n) { }
inline const T* operator->() const
{
@@ -244,12 +244,10 @@ template<typename T>
class Serialize::Reference : public ReferenceBase
{
protected:
- T *ref;
+ T *ref = nullptr;
public:
- Reference() : ref(NULL)
- {
- }
+ Reference() = default;
Reference(T *obj) : ref(obj)
{
diff --git a/include/servers.h b/include/servers.h
index f88f66187..5864b7e11 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -80,7 +80,7 @@ class CoreExport Server : public Extensible
public:
/* Number of users on the server */
- unsigned users;
+ unsigned users = 0;
/** Delete this server with a reason
* @param reason The reason
diff --git a/include/threadengine.h b/include/threadengine.h
index 14af252e6..e45987e26 100644
--- a/include/threadengine.h
+++ b/include/threadengine.h
@@ -19,16 +19,12 @@ class CoreExport Thread : public Pipe, public Extensible
{
private:
/* Set to true to tell the thread to finish and we are waiting for it */
- bool exit;
+ bool exit = false;
public:
/* Handle for this thread */
pthread_t handle;
- /** Threads constructor
- */
- Thread();
-
/** Threads destructor
*/
virtual ~Thread();
diff --git a/include/xline.h b/include/xline.h
index 1b032ded9..f00937ba0 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -23,8 +23,8 @@ class CoreExport XLine : public Serializable
Anope::string mask;
Regex *regex;
Anope::string by;
- time_t created;
- time_t expires;
+ time_t created = 0;
+ time_t expires = 0;
Anope::string reason;
XLineManager *manager;
Anope::string id;