]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix various warnings when building with LLVM 3.5.
authorPeter Powell <petpow@saberuk.com>
Mon, 6 Oct 2014 12:30:31 +0000 (13:30 +0100)
committerPeter Powell <petpow@saberuk.com>
Mon, 13 Oct 2014 05:18:10 +0000 (06:18 +0100)
- warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
- warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]

src/commands/cmd_whois.cpp
src/configparser.cpp
src/modules/m_spanningtree/idle.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/server.cpp

index ba2ad9c1526e1a83b8ad8f2518333f48de66270a..ab0b82fff4a3b77293e964a9c4e7b8ad4e0afcd7 100644 (file)
@@ -76,7 +76,7 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User
                 */
                if (IS_LOCAL(dest) && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1))
                {
-                       idle = abs((long)((dest->idle_lastmsg)-ServerInstance->Time()));
+                       idle = labs((long)((dest->idle_lastmsg)-ServerInstance->Time()));
                        signon = dest->signon;
                }
 
index 825dfc966c19b520c6216432ae72ede47b733da0..94192a71bb9166c2e8bda7124793f96c260fbe91 100644 (file)
@@ -390,8 +390,17 @@ bool ParseStack::ParseExec(const std::string& name, int flags, const std::string
 
 bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf)
 {
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunknown-pragmas"
+# pragma clang diagnostic ignored "-Wundefined-bool-conversion"
+#endif
+       // TODO: this is undefined behaviour but changing the API is too risky for 2.0.
        if (!this)
                return false;
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
        for(std::vector<KeyVal>::iterator j = items.begin(); j != items.end(); ++j)
        {
                if(j->first != key)
index 0ea06a3cc8ce9ff79d8e21de18fcb24f26d3b6ce..18aeb0ad5ff26aff90cfc8a2af14f17349a3b3ba 100644 (file)
@@ -40,7 +40,7 @@ bool TreeSocket::Whois(const std::string &prefix, parameterlist &params)
                        User* x = ServerInstance->FindNick(params[0]);
                        if ((x) && (IS_LOCAL(x)))
                        {
-                               long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time()));
+                               long idle = labs((long)((x->idle_lastmsg) - ServerInstance->Time()));
                                parameterlist par;
                                par.push_back(prefix);
                                par.push_back(ConvToStr(x->signon));
index fb658c9c7a1a3d402d9485320d4ff50b247dbe9b..acb822fbfa169419b2021fca91b9c4d2c984b49e 100644 (file)
@@ -155,13 +155,13 @@ void TreeSocket::ProcessLine(std::string &line)
                                        time_t delta = them - ServerInstance->Time();
                                        if ((delta < -600) || (delta > 600))
                                        {
-                                               ServerInstance->SNO->WriteGlobalSno('l',"\2ERROR\2: Your clocks are out by %d seconds (this is more than five minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs((long)delta));
-                                               SendError("Your clocks are out by "+ConvToStr(abs((long)delta))+" seconds (this is more than five minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
+                                               ServerInstance->SNO->WriteGlobalSno('l',"\2ERROR\2: Your clocks are out by %ld seconds (this is more than five minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",labs((long)delta));
+                                               SendError("Your clocks are out by "+ConvToStr(labs((long)delta))+" seconds (this is more than five minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
                                                return;
                                        }
                                        else if ((delta < -30) || (delta > 30))
                                        {
-                                               ServerInstance->SNO->WriteGlobalSno('l',"\2WARNING\2: Your clocks are out by %d seconds. Please consider synching your clocks.", abs((long)delta));
+                                               ServerInstance->SNO->WriteGlobalSno('l',"\2WARNING\2: Your clocks are out by %ld seconds. Please consider synching your clocks.", labs((long)delta));
                                        }
                                }
 
index 4741f942d53d2b5e838ddf52f1f16f5a435aeb92..d05ece8a45ac2c7f86bce4308dbb3fcc598687c9 100644 (file)
@@ -46,13 +46,10 @@ void InspIRCd::Exit(int status)
 #ifdef _WIN32
        SetServiceStopped(status);
 #endif
-       if (this)
-       {
-               this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
-               this->Cleanup();
-               delete this;
-               ServerInstance = NULL;
-       }
+       this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
+       this->Cleanup();
+       delete this;
+       ServerInstance = NULL;
        exit (status);
 }