]> granicus.if.org Git - icinga2/commitdiff
Fix compiler warnings
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 24 Aug 2016 17:59:13 +0000 (19:59 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 24 Aug 2016 18:33:34 +0000 (20:33 +0200)
fixes #12534

25 files changed:
icinga-app/icinga.cpp
icinga-studio/mainform.cpp
lib/base/array.cpp
lib/base/configobject.ti
lib/base/dictionary.cpp
lib/base/exception.hpp
lib/base/socketevents-poll.cpp
lib/cli/clicommand.cpp
lib/cli/consolecommand.cpp
lib/cli/consolecommand.hpp
lib/config/config_parser.yy
lib/config/expression.hpp
lib/db_ido/dbconnection.cpp
lib/db_ido/hostdbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/db_ido_mysql/idomysqlconnection.hpp
lib/icinga/cib.cpp
lib/livestatus/table.cpp
lib/perfdata/influxdbwriter.cpp
lib/remote/createobjecthandler.cpp
lib/remote/eventqueue.hpp
lib/remote/httphandler.cpp
lib/remote/httpserverconnection.cpp
lib/remote/jsonrpcconnection.cpp
tools/mkclass/classcompiler.cpp

index 0fea800ba4abc440b0daadf1d92475b2c2d1b243..0887f4d5f878196da3f05f81aab339e483eee027 100644 (file)
@@ -461,14 +461,14 @@ int Main(void)
                if (vm.count("arg"))
                        args = vm["arg"].as<std::vector<std::string> >();
 
-               if (args.size() < command->GetMinArguments()) {
+               if (static_cast<int>(args.size()) < command->GetMinArguments()) {
                        Log(LogCritical, "cli")
                            << "Too few arguments. Command needs at least " << command->GetMinArguments()
                            << " argument" << (command->GetMinArguments() != 1 ? "s" : "") << ".";
                        return EXIT_FAILURE;
                }
 
-               if (command->GetMaxArguments() >= 0 && args.size() > command->GetMaxArguments()) {
+               if (command->GetMaxArguments() >= 0 && static_cast<int>(args.size()) > command->GetMaxArguments()) {
                        Log(LogCritical, "cli")
                            << "Too many arguments. At most " << command->GetMaxArguments()
                            << " argument" << (command->GetMaxArguments() != 1 ? "s" : "") << " may be specified.";
index 0ca10814d5f3835d19c025f97e560af947d2078f..a441a74487e024ba3cfb5b6d7d107641d5eccc8b 100644 (file)
@@ -182,12 +182,10 @@ wxPGProperty *MainForm::ValueToProperty(const String& name, const Value& value)
        wxPGProperty *prop;
 
        if (value.IsNumber()) {
-               double val = value;
                prop = new wxFloatProperty(name.GetData(), wxPG_LABEL, value);
                prop->SetAttribute(wxPG_ATTR_UNITS, "Number");
                return prop;
        } else if (value.IsBoolean()) {
-               bool val = value;
                prop = new wxBoolProperty(name.GetData(), wxPG_LABEL, value);
                prop->SetAttribute(wxPG_ATTR_UNITS, "Boolean");
                return prop;
index e849cc64a4a40127cada7bb45b1e116b325a1e3e..f38e41e6560c5274690f3b137e7b0f90f49e5405 100644 (file)
@@ -229,7 +229,7 @@ Value Array::GetFieldByName(const String& field, bool sandboxed, const DebugInfo
 
        ObjectLock olock(this);
 
-       if (index < 0 || index >= GetLength())
+       if (index < 0 || static_cast<size_t>(index) >= GetLength())
                BOOST_THROW_EXCEPTION(ScriptError("Array index '" + Convert::ToString(index) + "' is out of bounds.", debugInfo));
 
        return Get(index);
@@ -240,7 +240,12 @@ void Array::SetFieldByName(const String& field, const Value& value, const DebugI
        ObjectLock olock(this);
 
        int index = Convert::ToLong(field);
-       if (index >= GetLength())
+
+       if (index < 0)
+               BOOST_THROW_EXCEPTION(ScriptError("Array index '" + Convert::ToString(index) + "' is out of bounds.", debugInfo));
+
+       if (static_cast<size_t>(index) >= GetLength())
                Resize(index + 1);
+
        Set(index, value);
 }
index 571a7045e6112e3d3be7811fc77fb3c2aa3f7503..db4fedb990a4431f50116c9e4e20b22261e37ddb 100644 (file)
@@ -59,10 +59,10 @@ public:
                m_DebugInfo = di;
        }
 
-       inline virtual void Start(bool runtimeCreated)
+       inline virtual void Start(bool /* runtimeCreated */)
        { }
 
-       inline virtual void Stop(bool runtimeRemoved)
+       inline virtual void Stop(bool /* runtimeRemoved */)
        { }
 
 private:
index 6ac2fecae94e95e461f847613651453a1e8c46c4..df19aecb06e25c0a023b77b4c9420893130b6977 100644 (file)
@@ -198,7 +198,7 @@ String Dictionary::ToString(void) const
        return msgbuf.str();
 }
 
-Value Dictionary::GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const
+Value Dictionary::GetFieldByName(const String& field, bool, const DebugInfo& debugInfo) const
 {
        Value value;
 
@@ -208,7 +208,7 @@ Value Dictionary::GetFieldByName(const String& field, bool sandboxed, const Debu
                return GetPrototypeField(const_cast<Dictionary *>(this), field, false, debugInfo);
 }
 
-void Dictionary::SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo)
+void Dictionary::SetFieldByName(const String& field, const Value& value, const DebugInfo&)
 {
        Set(field, value);
 }
index 935eaecd0d6408bf42a07a8725f66a979568835b..04b20be2404d117b84dae3167ebbb9ecaa5ed8b3 100644 (file)
@@ -106,7 +106,7 @@ I2_BASE_API void RethrowUncaughtException(void);
 
 typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
 
-inline std::string to_string(const StackTraceErrorInfo& e)
+inline std::string to_string(const StackTraceErrorInfo&)
 {
        return "";
 }
index 3532f5658de88c34c59b47697c7a558035291bfe..a84b3bc4fc3a046dde00d66330f7d82ba1dbabca 100644 (file)
@@ -91,7 +91,7 @@ void SocketEventEnginePoll::ThreadProc(int tid)
                        if (m_FDChanged[tid])
                                continue;
 
-                       for (int i = 0; i < pfds.size(); i++) {
+                       for (std::vector<pollfd>::size_type i = 0; i < pfds.size(); i++) {
                                if ((pfds[i].revents & (POLLIN | POLLOUT | POLLHUP | POLLERR)) == 0)
                                        continue;
 
index b1daec64de26185509c91e375a69a3ebc17e79ef..2ef3128f23b5e67d404cc72860c71b7ce7330a6e 100644 (file)
@@ -176,7 +176,9 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
        BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
                const std::vector<String>& vname = kv.first;
 
-               for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
+               std::vector<String>::size_type i;
+               int k;
+               for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
                        if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
                                i--;
                                continue;
@@ -237,14 +239,16 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
 
                arg_begin = 0;
 
-               for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
+               std::vector<String>::size_type i;
+               int k;
+               for (i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
                        if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
                                i--;
                                arg_begin++;
                                continue;
                        }
 
-                       if (autocomplete && i >= autoindex - 1)
+                       if (autocomplete && static_cast<int>(i) >= autoindex - 1)
                                break;
 
                        if (vname[i] != argv[k])
@@ -267,7 +271,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
                if (autoindex < argc)
                        aword = argv[autoindex];
 
-               if (autoindex - 1 > best_match.size() && !command)
+               if (autoindex - 1 > static_cast<int>(best_match.size()) && !command)
                        return;
        } else
                std::cout << "Supported commands: " << std::endl;
@@ -280,7 +284,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
 
                bool match = true;
 
-               for (int i = 0; i < best_match.size(); i++) {
+               for (std::vector<String>::size_type i = 0; i < best_match.size(); i++) {
                        if (vname[i] != best_match[i]) {
                                match = false;
                                break;
@@ -293,7 +297,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
                if (autocomplete) {
                        String cname;
 
-                       if (autoindex - 1 < vname.size()) {
+                       if (autoindex - 1 < static_cast<int>(vname.size())) {
                                cname = vname[autoindex - 1];
 
                                if (cname.Find(aword) == 0)
index a5d78292d5fd95d1fdc8f076feba71f705595746..786cf641f905334f018edc67bf24f5bb1f0ee9ac 100644 (file)
@@ -175,7 +175,7 @@ char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state)
                }
        }
 
-       if (state >= matches.size())
+       if (state >= static_cast<int>(matches.size()))
                return NULL;
 
        return strdup(matches[state].CStr());
index 65a7061b6fc2493d0d12fd0981b0658839513284..978848e04490d8ead08ba1892babf57b7578bb47 100644 (file)
@@ -52,7 +52,6 @@ public:
 private:
        mutable boost::mutex m_Mutex;
        mutable boost::condition_variable m_CV;
-       mutable bool m_CommandReady;
 
        static void ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv,
            bool& ready, boost::exception_ptr eptr, const Value& result, Value& resultOut,
index e778bf1b21034b6eabe03f5cb95aa98ea3b922cc..b4038f0ed165640e3814f365c2a02f22188b0a09 100644 (file)
@@ -281,7 +281,7 @@ Expression *ConfigCompiler::Compile(void)
 
        std::vector<Expression *> dlist;
        typedef std::pair<Expression *, EItemInfo> EListItem;
-       int num = 0;
+       std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
        BOOST_FOREACH(const EListItem& litem, llist) {
                if (!litem.second.SideEffect && num != llist.size() - 1) {
                        yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
@@ -778,7 +778,7 @@ rterm_scope: '{'
                context->m_IgnoreNewlines.pop();
                std::vector<Expression *> dlist;
                typedef std::pair<Expression *, EItemInfo> EListItem;
-               int num = 0;
+               std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
                BOOST_FOREACH(const EListItem& litem, *$3) {
                        if (!litem.second.SideEffect && num != $3->size() - 1)
                                yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
@@ -1006,7 +1006,7 @@ rterm_no_side_effect_no_dict: T_STRING
 
                std::vector<Expression *> dlist;
                typedef std::pair<Expression *, EItemInfo> EListItem;
-               int num = 0;
+               std::vector<std::pair<Expression *, EItemInfo> >::size_type num = 0;
                BOOST_FOREACH(const EListItem& litem, *$3) {
                        if (!litem.second.SideEffect && num != $3->size() - 1)
                                yyerror(&litem.second.DebugInfo, NULL, NULL, "Value computed is not used.");
index 47f2627cfd0572a7373eaaa7a4f90aefcd8d037b..c20fe9d157bdbf13525b21cc992b71e231577754 100644 (file)
@@ -799,7 +799,7 @@ class I2_CONFIG_API FunctionExpression : public DebuggableExpression
 public:
        FunctionExpression(const String& name, const std::vector<String>& args,
            std::map<String, Expression *> *closedVars, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
-               : DebuggableExpression(debugInfo), m_Args(args), m_Name(name), m_ClosedVars(closedVars), m_Expression(expression)
+               : DebuggableExpression(debugInfo), m_Name(name), m_Args(args), m_ClosedVars(closedVars), m_Expression(expression)
        { }
 
        ~FunctionExpression(void)
index 329c93bac9e3942dfabb94c9996807d244d1122c..973424d7d6d83274c7923f134639f8c5c24997cd 100644 (file)
@@ -39,8 +39,8 @@ Timer::Ptr DbConnection::m_ProgramStatusTimer;
 boost::once_flag DbConnection::m_OnceFlag = BOOST_ONCE_INIT;
 
 DbConnection::DbConnection(void)
-       : m_QueryStats(15 * 60), m_PendingQueries(0), m_PendingQueriesTimestamp(0),
-         m_IDCacheValid(false), m_ActiveChangedHandler(false)
+       : m_IDCacheValid(false), m_QueryStats(15 * 60), m_PendingQueries(0),
+         m_PendingQueriesTimestamp(0), m_ActiveChangedHandler(false)
 { }
 
 void DbConnection::OnConfigLoaded(void)
@@ -255,7 +255,7 @@ void DbConnection::CleanUpHandler(void)
                { "downtimehistory", "entry_time" },
                { "eventhandlers", "start_time" },
                { "externalcommands", "entry_time" },
-               { "flappinghistory" "event_time" },
+               { "flappinghistory", "event_time" },
                { "hostchecks", "start_time" },
                { "logentries", "logentry_time" },
                { "notifications", "start_time" },
index 30ef27a3076cf16f7ace0a8a5b6f78be9ca90038..d607531f2f385bce1835f57137178c93a8d8d9d0 100644 (file)
@@ -427,8 +427,6 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co
                if (!parent)
                        continue;
 
-               int state_filter = dep->GetStateFilter();
-
                Array::Ptr depInfo = new Array();
                depInfo->Add(parent->GetName());
                depInfo->Add(dep->GetStateFilter());
index b9009097f694b892177dcacab26ec8cef2e2cf7b..ca3a5a2e05fad4e154228432c8713f408d4fc0ae 100644 (file)
@@ -371,8 +371,6 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields)
                if (!parent)
                        continue;
 
-               int state_filter = dep->GetStateFilter();
-
                Array::Ptr depInfo = new Array();
                depInfo->Add(parent->GetName());
                depInfo->Add(dep->GetStateFilter());
index 5920de67b5876e11b6f48be05f7e05795891ec0a..2115a9d2e640832efc61be11c41e159081b11628 100644 (file)
@@ -76,7 +76,7 @@ private:
 
        MYSQL m_Connection;
        int m_AffectedRows;
-       int m_MaxPacketSize;
+       unsigned int m_MaxPacketSize;
 
        std::vector<IdoAsyncQuery> m_AsyncQueries;
 
index e8724c5711fe83301be0c5ef4756af63c288c2b6..38aec3baaa8e11cd9ad98188d0bc75790467e4ee 100644 (file)
@@ -198,7 +198,7 @@ CheckableCheckStatistics CIB::CalculateServiceCheckStats(void)
 
 ServiceStatistics CIB::CalculateServiceStats(void)
 {
-       ServiceStatistics ss = {0};
+       ServiceStatistics ss = {};
 
        BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType<Service>()) {
                ObjectLock olock(service);
@@ -232,7 +232,7 @@ ServiceStatistics CIB::CalculateServiceStats(void)
 
 HostStatistics CIB::CalculateHostStats(void)
 {
-       HostStatistics hs = {0};
+       HostStatistics hs = {};
 
        BOOST_FOREACH(const Host::Ptr& host, ConfigType::GetObjectsByType<Host>()) {
                ObjectLock olock(host);
index c176100001ade987b360943ca9e087df42de45d0..acec7be53b2fc7ce6debacf63f9c4d2292afaa2a 100644 (file)
@@ -138,7 +138,7 @@ std::vector<LivestatusRowValue> Table::FilterRows(const Filter::Ptr& filter, int
 
 bool Table::FilteredAddRow(std::vector<LivestatusRowValue>& rs, const Filter::Ptr& filter, int limit, const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject)
 {
-       if (limit != -1 && rs.size() == limit)
+       if (limit != -1 && static_cast<int>(rs.size()) == limit)
                return false;
 
        if (!filter || filter->Apply(this, row)) {
index 239db8995fd9a98f37b177f2db7d48e57c3d872e..d401bf0bad4b48689a69dcbcaeb54db140446583 100644 (file)
@@ -148,7 +148,6 @@ void InfluxdbWriter::CheckResultHandler(const Checkable::Ptr& checkable, const C
        Dictionary::Ptr tags = tmpl->Get("tags");
        if (tags) {
                ObjectLock olock(tags);
-retry:
                BOOST_FOREACH(const Dictionary::Pair& pair, tags) {
                        // Prevent missing macros from warning; will return an empty value
                        // which will be filtered out in SendMetric()
@@ -318,7 +317,7 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label
        m_DataBuffer->Add(String(msgbuf.str()));
 
        // Flush if we've buffered too much to prevent excessive memory use
-       if (m_DataBuffer->GetLength() >= GetFlushThreshold()) {
+       if (static_cast<int>(m_DataBuffer->GetLength()) >= GetFlushThreshold()) {
                Log(LogDebug, "InfluxdbWriter")
                    << "Data buffer overflow writing " << m_DataBuffer->GetLength() << " data points";
                Flush();
index 848512be3a829e0edc7b52cfddec2243294d9d7f..bcb0b256cfd191623758613574cc470243fdebe3 100644 (file)
@@ -52,7 +52,6 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
        Dictionary::Ptr attrs = params->Get("attrs");
 
        Dictionary::Ptr result1 = new Dictionary();
-       int code;
        String status;
        Array::Ptr errors = new Array();
 
index 6e62f5f07a3ecb9c2dc6767cca9e0d2ca1c8c60a..b34b36c8b82f9108c5824b9e167326ed90b669f1 100644 (file)
@@ -64,7 +64,6 @@ private:
 
        std::set<String> m_Types;
        Expression *m_Filter;
-       double m_Ttl;
 
        std::map<void *, std::deque<Dictionary::Ptr> > m_Events;
 };
index 24db6ce4404f8cf697c1e831a47b7b42e21291c5..041136b4760e9be2f57836a83c12d585145362bb 100644 (file)
@@ -67,7 +67,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
        std::vector<HttpHandler::Ptr> handlers;
        const std::vector<String>& path = request.RequestUrl->GetPath();
 
-       for (int i = 0; i <= path.size(); i++) {
+       for (std::vector<String>::size_type i = 0; i <= path.size(); i++) {
                Array::Ptr current_handlers = node->Get("handlers");
 
                if (current_handlers) {
index d3f75868bd9cf19782330c5dbba98606cd58046d..140fbde014b9ad76c3450744f615378ac54d1195 100644 (file)
@@ -37,7 +37,7 @@ static boost::once_flag l_HttpServerConnectionOnceFlag = BOOST_ONCE_INIT;
 static Timer::Ptr l_HttpServerConnectionTimeoutTimer;
 
 HttpServerConnection::HttpServerConnection(const String& identity, bool authenticated, const TlsStream::Ptr& stream)
-       : m_Stream(stream), m_CurrentRequest(stream), m_Seen(Utility::GetTime()), m_PendingRequests(0)
+       : m_Stream(stream), m_Seen(Utility::GetTime()), m_CurrentRequest(stream), m_PendingRequests(0)
 {
        boost::call_once(l_HttpServerConnectionOnceFlag, &HttpServerConnection::StaticInitialize);
 
index 69321a63ebb0f8a7129836950f0717b6b0232176..ccc090bd500aa31d08474b60810bc612a1509b0e 100644 (file)
@@ -64,7 +64,7 @@ void JsonRpcConnection::StaticInitialize(void)
        l_JsonRpcConnectionWorkQueueCount = Application::GetConcurrency();
        l_JsonRpcConnectionWorkQueues = new WorkQueue[l_JsonRpcConnectionWorkQueueCount];
 
-       for (int i = 0; i < l_JsonRpcConnectionWorkQueueCount; i++) {
+       for (size_t i = 0; i < l_JsonRpcConnectionWorkQueueCount; i++) {
                l_JsonRpcConnectionWorkQueues[i].SetName("JsonRpcConnection, #" + Convert::ToString(i));
        }
 }
index 1e8b1d2a076fe016d764baa2454f7ff3c36ef3cd..6f88c87517a0505fd333a2fd77afdc6e8a21eb7d 100644 (file)
@@ -106,7 +106,7 @@ void ClassCompiler::HandleCode(const std::string& code, const ClassDebugInfo&)
        m_Header << code << std::endl;
 }
 
-void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugInfo& locp)
+void ClassCompiler::HandleLibrary(const std::string& library, const ClassDebugInfo&)
 {
        m_Library = library;