]> granicus.if.org Git - icinga2/commitdiff
Suppress or fix compiler warnings 6999/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 8 Mar 2019 13:07:29 +0000 (14:07 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 8 Mar 2019 13:07:29 +0000 (14:07 +0100)
icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/netstring.cpp
lib/base/process.cpp
lib/base/scriptframe.cpp
lib/cli/consolecommand.cpp
lib/cli/nodesetupcommand.cpp
lib/icinga/legacytimeperiod.cpp
lib/icinga/scheduleddowntime.cpp
lib/remote/apilistener.cpp
lib/remote/eventqueue.cpp

index e8d3f5bf37bcf8fc611cabaecdfa8dcc6c0bb426..3490b49e999882fcaddc1f0b19218540473f7e81 100644 (file)
@@ -940,6 +940,8 @@ int main(int argc, char **argv)
 #ifdef I2_DEBUG
                                if (rc >= 0)
                                        std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
+#else /* I2_DEBUG */
+                               (void)rc;
 #endif /* I2_DEBUG */
                        }
                }
index df93710b71016312d91a152046439f3544e43b0b..1effde6179f2096491be32bfa7031dc5673d0421 100644 (file)
@@ -171,7 +171,7 @@ void Application::SetResourceLimits()
        rlim_t fileLimit = Configuration::RLimitFiles;
 
        if (fileLimit != 0) {
-               if (fileLimit < GetDefaultRLimitFiles()) {
+               if (fileLimit < (rlim_t)GetDefaultRLimitFiles()) {
                        Log(LogWarning, "Application")
                                << "The user-specified value for RLimitFiles cannot be smaller than the default value (" << GetDefaultRLimitFiles() << "). Using the default value instead.";
                        fileLimit = GetDefaultRLimitFiles();
@@ -192,7 +192,7 @@ void Application::SetResourceLimits()
        rlim_t processLimit = Configuration::RLimitProcesses;
 
        if (processLimit != 0) {
-               if (processLimit < GetDefaultRLimitProcesses()) {
+               if (processLimit < (rlim_t)GetDefaultRLimitProcesses()) {
                        Log(LogWarning, "Application")
                                << "The user-specified value for RLimitProcesses cannot be smaller than the default value (" << GetDefaultRLimitProcesses() << "). Using the default value instead.";
                        processLimit = GetDefaultRLimitProcesses();
@@ -231,7 +231,7 @@ void Application::SetResourceLimits()
        stackLimit = Configuration::RLimitStack;
 
        if (stackLimit != 0) {
-               if (stackLimit < GetDefaultRLimitStack()) {
+               if (stackLimit < (rlim_t)GetDefaultRLimitStack()) {
                        Log(LogWarning, "Application")
                                << "The user-specified value for RLimitStack cannot be smaller than the default value (" << GetDefaultRLimitStack() << "). Using the default value instead.";
                        stackLimit = GetDefaultRLimitStack();
index 5bc026167cdfa64f8aa98402b220e383ab8f5ac0..17789b2d5bcaec04d393c82b53572a91a114c5c8 100644 (file)
@@ -85,7 +85,7 @@ StreamReadStatus NetString::ReadStringFromStream(const Stream::Ptr& stream, Stri
        /* read the whole message */
        size_t data_length = len + 1;
 
-       if (maxMessageLength >= 0 && data_length > maxMessageLength) {
+       if (maxMessageLength >= 0 && data_length > (size_t)maxMessageLength) {
                std::stringstream errorMessage;
                errorMessage << "Max data length exceeded: " << (maxMessageLength / 1024) << " KB";
 
index 71454b5acdfa55feb4f8027d1ab5cf26992cd2a6..852acc81885b6b9f143d1161e28457a75a33eb80 100644 (file)
@@ -164,8 +164,11 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
                (void)close(fds[2]);
 
 #ifdef HAVE_NICE
-               if (adjustPriority)
-                       (void)nice(5);
+               if (adjustPriority) {
+                       // Cheating the compiler on "warning: ignoring return value of 'int nice(int)', declared with attribute warn_unused_result [-Wunused-result]".
+                       auto x (nice(5));
+                       (void)x;
+               }
 #endif /* HAVE_NICE */
 
                sigset_t mask;
index ebb6399b376544dc6c2048e29999c865b03ef211..be37416ee1edebc46db7741c4c01d5774768e78a 100644 (file)
@@ -90,6 +90,10 @@ ScriptFrame::~ScriptFrame()
 {
        ScriptFrame *frame = PopFrame();
        ASSERT(frame == this);
+
+#ifndef I2_DEBUG
+       (void)frame;
+#endif /* I2_DEBUG */
 }
 
 void ScriptFrame::IncreaseStackDepth()
index 86019022a8f6f541aa44f9527fbadb2b36259e04..92cf9a4c2c937d9875aaf3b180aba4b4ddc9f00f 100644 (file)
@@ -476,15 +476,15 @@ incomplete:
 
                                std::vector<String> ulines = text.Split("\n");
 
-                               for (int i = 1; i <= ulines.size(); i++) {
+                               for (decltype(ulines.size()) i = 1; i <= ulines.size(); i++) {
                                        int start, len;
 
-                                       if (i == di.FirstLine)
+                                       if (i == (decltype(i))di.FirstLine)
                                                start = di.FirstColumn;
                                        else
                                                start = 0;
 
-                                       if (i == di.LastLine)
+                                       if (i == (decltype(i))di.LastLine)
                                                len = di.LastColumn - di.FirstColumn + 1;
                                        else
                                                len = ulines[i - 1].GetLength();
@@ -497,7 +497,7 @@ incomplete:
                                        } else
                                                offset = 4;
 
-                                       if (i >= di.FirstLine && i <= di.LastLine) {
+                                       if (i >= (decltype(i))di.FirstLine && i <= (decltype(i))di.LastLine) {
                                                std::cout << String(di.Path.GetLength() + offset, ' ');
                                                std::cout << String(start, ' ') << String(len, '^') << "\n";
                                        }
index 166c8425b4a9b965173d19989581392039b16cb3..f772a0f375b391cc16f1d339d875bc767a48c413 100644 (file)
@@ -170,7 +170,7 @@ int NodeSetupCommand::SetupMaster(const boost::program_options::variables_map& v
        if (vm.count("global_zones"))
                setupGlobalZones = vm["global_zones"].as<std::vector<std::string> >();
 
-       for (int i = 0; i < setupGlobalZones.size(); i++) {
+       for (decltype(setupGlobalZones.size()) i = 0; i < setupGlobalZones.size(); i++) {
                if (std::find(globalZones.begin(), globalZones.end(), setupGlobalZones[i]) != globalZones.end()) {
                        Log(LogCritical, "cli")
                                << "The global zone '" << setupGlobalZones[i] << "' is already specified.";
@@ -522,7 +522,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
        if (vm.count("global_zones"))
                setupGlobalZones = vm["global_zones"].as<std::vector<std::string> >();
 
-       for (int i = 0; i < setupGlobalZones.size(); i++) {
+       for (decltype(setupGlobalZones.size()) i = 0; i < setupGlobalZones.size(); i++) {
                if (std::find(globalZones.begin(), globalZones.end(), setupGlobalZones[i]) != globalZones.end()) {
                        Log(LogCritical, "cli")
                                << "The global zone '" << setupGlobalZones[i] << "' is already specified.";
index 6433d0d6cc208a6327376feb96b2647adca5c5a0..8ac54e4e82195878152276b3f87ad5e7e1f893c1 100644 (file)
@@ -408,7 +408,7 @@ Dictionary::Ptr LegacyTimePeriod::FindRunningSegment(const String& daydef, const
                        ProcessTimeRanges(timeranges, &iter, segments);
 
                        Dictionary::Ptr bestSegment;
-                       double bestEnd;
+                       double bestEnd = 0.0;
 
                        ObjectLock olock(segments);
                        for (const Dictionary::Ptr& segment : segments) {
index 37c3693bde02864a207dcdb251059fedc9862dfc..9e6c1b55260ad16cf31315b3d3d0a335f2597df9 100644 (file)
@@ -136,7 +136,7 @@ std::pair<double, double> ScheduledDowntime::FindRunningSegment(double minEnd)
        Array::Ptr segments = new Array();
 
        Dictionary::Ptr bestSegment;
-       double bestBegin, bestEnd;
+       double bestBegin = 0.0, bestEnd = 0.0;
        double now = Utility::GetTime();
 
        ObjectLock olock(ranges);
@@ -196,7 +196,7 @@ std::pair<double, double> ScheduledDowntime::FindNextSegment()
        Array::Ptr segments = new Array();
 
        Dictionary::Ptr bestSegment;
-       double bestBegin, bestEnd;
+       double bestBegin = 0.0, bestEnd = 0.0;
        double now = Utility::GetTime();
 
        ObjectLock olock(ranges);
index 9596b76ac42ec5f13aed4f9f72e27a6bbbf7ca29..a391bf430683056d1475893eaa4d141443465ef9 100644 (file)
@@ -1424,7 +1424,7 @@ bool ApiListener::AddAnonymousClient(const JsonRpcConnection::Ptr& aclient)
 {
        boost::mutex::scoped_lock lock(m_AnonymousClientsLock);
 
-       if (GetMaxAnonymousClients() >= 0 && m_AnonymousClients.size() + 1 > GetMaxAnonymousClients())
+       if (GetMaxAnonymousClients() >= 0 && (long)m_AnonymousClients.size() + 1 > (long)GetMaxAnonymousClients())
                return false;
 
        m_AnonymousClients.insert(aclient);
index d724517711aeb7091f57812f653c34db0a80363d..df26701a6e30fe69b3715fac07b25d37f045bb51 100644 (file)
@@ -65,6 +65,10 @@ void EventQueue::AddClient(void *client)
 
        auto result = m_Events.insert(std::make_pair(client, std::deque<Dictionary::Ptr>()));
        ASSERT(result.second);
+
+#ifndef I2_DEBUG
+       (void)result;
+#endif /* I2_DEBUG */
 }
 
 void EventQueue::RemoveClient(void *client)