diff --git a/include/config.h b/include/config.h index 592bb82bd..7f25dbce1 100644 --- a/include/config.h +++ b/include/config.h @@ -35,7 +35,7 @@ namespace Configuration Anope::string name; ItemMap items; BlockMap blocks; - int linenum; + unsigned linenum; /* Represents a missing tag. */ static Block EmptyBlock; @@ -43,10 +43,10 @@ namespace Configuration public: Block(const Anope::string &); const Anope::string &GetName() const; - int CountBlock(const Anope::string &name) const; + size_t CountBlock(const Anope::string &name) const; BlockList GetBlocks(const Anope::string &name) const; - const Block &GetBlock(const Anope::string &name, int num = 0) const; - Block *GetMutableBlock(const Anope::string &name, int num = 0); + const Block &GetBlock(const Anope::string &name, size_t num = 0) const; + Block *GetMutableBlock(const Anope::string &name, size_t num = 0); template T Get(const Anope::string &tag, const Anope::string &def = "") const { @@ -88,7 +88,7 @@ namespace Configuration { private: /** Replaces defined variables within a string. */ - Anope::string ReplaceVars(const Anope::string &str, const File &file, int linenumber); + Anope::string ReplaceVars(const Anope::string &str, const File &file, unsigned linenumber); public: /* options:readtimeout */ diff --git a/modules/extra/ldap.cpp b/modules/extra/ldap.cpp index a583d6a4d..540f19895 100644 --- a/modules/extra/ldap.cpp +++ b/modules/extra/ldap.cpp @@ -634,7 +634,7 @@ public: { const Anope::string &cname = it->first; LDAPService *s = it->second; - int i; + size_t i; ++it; diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index 9fdf781e3..33bad8f72 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -281,7 +281,7 @@ public: { const Anope::string &cname = it->first; MySQLService *s = it->second; - int i; + size_t i; ++it; diff --git a/modules/extra/sqlite.cpp b/modules/extra/sqlite.cpp index f77237949..4be111406 100644 --- a/modules/extra/sqlite.cpp +++ b/modules/extra/sqlite.cpp @@ -129,7 +129,7 @@ public: { const Anope::string &cname = it->first; SQLiteService *s = it->second; - int i, num; + size_t i, num; ++it; for (i = 0, num = config.CountBlock("sqlite"); i < num; ++i) diff --git a/src/config.cpp b/src/config.cpp index 14d514f55..0ef3e5f13 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -38,7 +38,7 @@ const Anope::string &Configuration::Block::GetName() const return name; } -int Configuration::Block::CountBlock(const Anope::string &bname) const +size_t Configuration::Block::CountBlock(const Anope::string &bname) const { return blocks.count(bname); } @@ -48,23 +48,27 @@ Configuration::Block::BlockList Configuration::Block::GetBlocks(const Anope::str return Anope::equal_range(blocks, bname); } -const Configuration::Block &Configuration::Block::GetBlock(const Anope::string &bname, int num) const +const Configuration::Block &Configuration::Block::GetBlock(const Anope::string &bname, size_t num) const { auto it = blocks.equal_range(bname); - for (int i = 0; it.first != it.second; ++it.first, ++i) + for (size_t i = 0; it.first != it.second; ++it.first, ++i) + { if (i == num) return it.first->second; + } return EmptyBlock; } -Configuration::Block *Configuration::Block::GetMutableBlock(const Anope::string &bname, int num) +Configuration::Block *Configuration::Block::GetMutableBlock(const Anope::string &bname, size_t num) { auto it = blocks.equal_range(bname); - for (int i = 0; it.first != it.second; ++it.first, ++i) + for (size_t i = 0; it.first != it.second; ++it.first, ++i) + { if (i == num) return &it.first->second; + } return NULL; } @@ -766,7 +770,7 @@ void Configuration::Conf::LoadConf(Configuration::File &file) Anope::string itemname, wordbuffer; std::stack block_stack; - int linenumber = 0; + unsigned linenumber = 0; bool in_word = false, in_quote = false, in_comment = false; Log(LOG_DEBUG) << "Start to read conf " << file.GetPath(); @@ -968,7 +972,7 @@ void Configuration::Conf::LoadConf(Configuration::File &file) } } -Anope::string Configuration::Conf::ReplaceVars(const Anope::string &str, const Configuration::File &file, int linenumber) +Anope::string Configuration::Conf::ReplaceVars(const Anope::string &str, const Configuration::File &file, unsigned linenumber) { Anope::string ret; for (auto it = str.begin(); it != str.end(); )