[Libreoffice-commits] online.git: common/Png.hpp common/SigUtil.cpp common/Unit.cpp common/Unit.hpp configure.ac kit/Kit.cpp test/httpcrashtest.cpp test/httpwserror.cpp test/httpwstest.cpp test/integration-http-server.cpp test/TileCacheTests.cpp test/UnitFonts.cpp test/UnitPrefork.cpp test/UnitTimeout.cpp tools/Connect.cpp tools/map.cpp tools/mount.cpp

Noel Grandin noel.grandin at collabora.co.uk
Thu Dec 22 14:24:01 UTC 2016


 common/Png.hpp                   |    2 +-
 common/SigUtil.cpp               |   14 +++++++-------
 common/Unit.cpp                  |   12 ++++++------
 common/Unit.hpp                  |    2 +-
 configure.ac                     |    9 +++++++++
 kit/Kit.cpp                      |    2 +-
 test/TileCacheTests.cpp          |    4 ++--
 test/UnitFonts.cpp               |    2 +-
 test/UnitPrefork.cpp             |    4 ++--
 test/UnitTimeout.cpp             |    4 ++--
 test/httpcrashtest.cpp           |    2 +-
 test/httpwserror.cpp             |    2 +-
 test/httpwstest.cpp              |    2 +-
 test/integration-http-server.cpp |    2 +-
 tools/Connect.cpp                |    2 +-
 tools/map.cpp                    |    4 ++--
 tools/mount.cpp                  |    6 +++---
 17 files changed, 42 insertions(+), 33 deletions(-)

New commits:
commit 4ed820d3d55715f4699a2315ccd5ffd7222941cd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Dec 22 16:04:07 2016 +0200

    add a configure option for using clang compiler plugins
    
    and apply the nullptr plugin.
    
    Lots of hacking in my LO tree required to make this work, will probably
    end up needing to add an extra parameter to the LO side.
    
    Change-Id: I02ae1dcdece9d9ddf05f7757f6696e3a5d7d1f14
    Reviewed-on: https://gerrit.libreoffice.org/32339
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Tested-by: Tor Lillqvist <tml at collabora.com>

diff --git a/common/Png.hpp b/common/Png.hpp
index 3e2b473..2596300 100644
--- a/common/Png.hpp
+++ b/common/Png.hpp
@@ -208,7 +208,7 @@ std::vector<png_bytep> decodePNG(std::stringstream& stream, png_uint_32& height,
         throw std::runtime_error("Invalid PNG signature.");
     }
 
-    png_structp ptrPNG = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+    png_structp ptrPNG = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
     if (ptrPNG == nullptr)
     {
         throw std::runtime_error("png_create_read_struct failed.");
diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp
index 4a6882e..ee3c776 100644
--- a/common/SigUtil.cpp
+++ b/common/SigUtil.cpp
@@ -181,7 +181,7 @@ namespace SigUtil
         action.sa_flags = 0;
         action.sa_handler = SIG_DFL;
 
-        sigaction(signal, &action, NULL);
+        sigaction(signal, &action, nullptr);
 
         char header[32];
         sprintf(header, "Backtrace %d:\n", getpid());
@@ -192,7 +192,7 @@ namespace SigUtil
         if (numSlots > 0)
         {
             char **symbols = backtrace_symbols(backtraceBuffer, numSlots);
-            if (symbols != NULL)
+            if (symbols != nullptr)
             {
                 struct iovec ioVector[maxSlots*2+1];
                 ioVector[0].iov_base = (void*)header;
@@ -230,11 +230,11 @@ namespace SigUtil
         action.sa_flags = 0;
         action.sa_handler = handleFatalSignal;
 
-        sigaction(SIGSEGV, &action, NULL);
-        sigaction(SIGBUS, &action, NULL);
-        sigaction(SIGABRT, &action, NULL);
-        sigaction(SIGILL, &action, NULL);
-        sigaction(SIGFPE, &action, NULL);
+        sigaction(SIGSEGV, &action, nullptr);
+        sigaction(SIGBUS, &action, nullptr);
+        sigaction(SIGABRT, &action, nullptr);
+        sigaction(SIGILL, &action, nullptr);
+        sigaction(SIGFPE, &action, nullptr);
 
         // prepare this in advance just in case.
         std::ostringstream stream;
diff --git a/common/Unit.cpp b/common/Unit.cpp
index 80ae442..8d31f44 100644
--- a/common/Unit.cpp
+++ b/common/Unit.cpp
@@ -34,10 +34,10 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP
     if (!dlHandle)
     {
         LOG_ERR("Failed to load " << unitLibPath << ": " << dlerror());
-        return NULL;
+        return nullptr;
     }
 
-    const char *symbol = NULL;
+    const char *symbol = nullptr;
     switch (type)
     {
         case UnitType::Wsd:
@@ -52,7 +52,7 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP
     if (!createHooks)
     {
         LOG_ERR("No " << symbol << " symbol in " << unitLibPath);
-        return NULL;
+        return nullptr;
     }
     UnitBase *pHooks = createHooks();
 
@@ -99,7 +99,7 @@ bool UnitBase::init(UnitType type, const std::string &unitLibPath)
     if (Global)
         Global->_type = type;
 
-    return Global != NULL;
+    return Global != nullptr;
 }
 
 bool UnitBase::isUnitTesting()
@@ -114,7 +114,7 @@ void UnitBase::setTimeout(int timeoutMilliSeconds)
 }
 
 UnitBase::UnitBase()
-    : _dlHandle(NULL),
+    : _dlHandle(nullptr),
       _setRetValue(false),
       _retValue(0),
       _timeoutMilliSeconds(30 * 1000),
@@ -128,7 +128,7 @@ UnitBase::~UnitBase()
 // FIXME: we should really clean-up properly.
 //    if (_dlHandle)
 //        dlclose(_dlHandle);
-    _dlHandle = NULL;
+    _dlHandle = nullptr;
 }
 
 UnitWSD::UnitWSD()
diff --git a/common/Unit.hpp b/common/Unit.hpp
index daa3387..eb004c6 100644
--- a/common/Unit.hpp
+++ b/common/Unit.hpp
@@ -246,7 +246,7 @@ public:
     virtual LibreOfficeKit *lok_init(const char * /* instdir */,
                                      const char * /* userdir */)
     {
-        return NULL;
+        return nullptr;
     }
 };
 
diff --git a/configure.ac b/configure.ac
index 5655aa0..f803487 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,6 +100,11 @@ AC_ARG_WITH([max-connections],
             AS_HELP_STRING([--max-connections],
                            [Compile with a hard-coded limit on the total number of client connections]))
 
+AC_ARG_WITH([compiler-plugins],
+            AS_HELP_STRING([--with-compiler-plugins=<path>],
+                [Experimental! Unlikely to work for anyone except Noel! Enable compiler plugins that will perform additional checks during
+                 building.]))
+
 # Handle options
 AS_IF([test "$enable_debug" = yes -a -n "$with_poco_libs"],
       [POCO_DEBUG_SUFFIX=d],
@@ -292,6 +297,10 @@ while :; do
     test $LOOLWSD_CACHEDIR = $oldvalue && break
 done
 
+# need this after the other stuff that uses the compiler because we don't want to run configure-tests with the plugins enabled
+AS_IF([test -n "$with_compiler_plugins"],
+      [CPPFLAGS="$CPPFLAGS -Xclang -load -Xclang ${with_compiler_plugins}/compilerplugins/obj/plugin.so -Xclang -add-plugin -Xclang loplugin"])
+
 AC_DEFINE_UNQUOTED([LOOLWSD_CACHEDIR],["$LOOLWSD_CACHEDIR"],[Cache folder])
 AC_SUBST(LOOLWSD_CACHEDIR)
 
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index fe23e53..1e398bf 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1505,7 +1505,7 @@ void lokit_main(const std::string& childRoot,
             symlinkPathToJail(jailPath, loTemplate, loSubPath);
 
             // Font paths can end up as realpaths so match that too.
-            char *resolved = realpath(loTemplate.c_str(), NULL);
+            char *resolved = realpath(loTemplate.c_str(), nullptr);
             if (resolved)
             {
                 if (strcmp(loTemplate.c_str(), resolved) != 0)
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 7872193..30897a0 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -122,7 +122,7 @@ public:
         Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
         Poco::Net::Context::Params sslParams;
         Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        Poco::Net::SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        Poco::Net::SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 #endif
     }
 
@@ -900,7 +900,7 @@ void TileCacheTests::checkTiles(std::shared_ptr<LOOLWebSocket>& socket, const st
     }
 
     // random setclientpart
-    std::srand(std::time(0));
+    std::srand(std::time(nullptr));
     std::vector<int> vParts = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     std::random_shuffle(vParts.begin(), vParts.end());
     for (auto it : vParts)
diff --git a/test/UnitFonts.cpp b/test/UnitFonts.cpp
index 871c74b..96c86c7 100644
--- a/test/UnitFonts.cpp
+++ b/test/UnitFonts.cpp
@@ -31,7 +31,7 @@ namespace {
     // interrogate the vcl/ fontmanager for its hook ...
     std::string getFontList()
     {
-        void *me = dlopen(NULL,RTLD_NOW);
+        void *me = dlopen(nullptr,RTLD_NOW);
         typedef const char *(GetFontsFn)(void);
         GetFontsFn *fn = reinterpret_cast<GetFontsFn *>(
                                 dlsym(me, "unit_online_get_fonts"));
diff --git a/test/UnitPrefork.cpp b/test/UnitPrefork.cpp
index 6f4427d..9504c08 100644
--- a/test/UnitPrefork.cpp
+++ b/test/UnitPrefork.cpp
@@ -199,7 +199,7 @@ class UnitKitPrefork : public UnitKit
 
 public:
     UnitKitPrefork()
-        : _procSMaps(NULL)
+        : _procSMaps(nullptr)
     {
         std::cerr << "UnitKit Prefork init !\n";
     }
@@ -277,7 +277,7 @@ public:
                                      std::to_string(getpid()) +
                                      std::string("/smaps");
         _procSMaps = fopen(procName.c_str(), "r");
-        if (_procSMaps == NULL)
+        if (_procSMaps == nullptr)
         {
             _failure = "Failed to open process: " + procName;
             throw std::runtime_error(_failure);
diff --git a/test/UnitTimeout.cpp b/test/UnitTimeout.cpp
index 4cf3ed9..a5478b5 100644
--- a/test/UnitTimeout.cpp
+++ b/test/UnitTimeout.cpp
@@ -53,11 +53,11 @@ public:
         bool madeWSD = init(UnitType::Wsd, std::string());
         assert(madeWSD);
         delete UnitBase::Global;
-        UnitBase::Global = NULL;
+        UnitBase::Global = nullptr;
         bool madeKit = init(UnitType::Kit, std::string());
         assert(madeKit);
         delete UnitBase::Global;
-        UnitBase::Global = NULL;
+        UnitBase::Global = nullptr;
     }
 };
 
diff --git a/test/httpcrashtest.cpp b/test/httpcrashtest.cpp
index a4a4ff3..55bad24 100644
--- a/test/httpcrashtest.cpp
+++ b/test/httpcrashtest.cpp
@@ -81,7 +81,7 @@ public:
         Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
         Poco::Net::Context::Params sslParams;
         Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        Poco::Net::SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        Poco::Net::SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 #endif
     }
 
diff --git a/test/httpwserror.cpp b/test/httpwserror.cpp
index 67fd235..3db733d 100644
--- a/test/httpwserror.cpp
+++ b/test/httpwserror.cpp
@@ -57,7 +57,7 @@ public:
         Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
         Poco::Net::Context::Params sslParams;
         Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        Poco::Net::SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        Poco::Net::SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 #endif
     }
 
diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp
index d180820..fbf00da 100644
--- a/test/httpwstest.cpp
+++ b/test/httpwstest.cpp
@@ -178,7 +178,7 @@ public:
         Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
         Poco::Net::Context::Params sslParams;
         Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        Poco::Net::SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        Poco::Net::SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 #endif
     }
 
diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp
index 9ca4ec1..f0d2c50 100644
--- a/test/integration-http-server.cpp
+++ b/test/integration-http-server.cpp
@@ -70,7 +70,7 @@ public:
         Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::AcceptCertificateHandler(false);
         Poco::Net::Context::Params sslParams;
         Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        Poco::Net::SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        Poco::Net::SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 #endif
     }
 
diff --git a/tools/Connect.cpp b/tools/Connect.cpp
index 92dad7c..6501d44 100644
--- a/tools/Connect.cpp
+++ b/tools/Connect.cpp
@@ -169,7 +169,7 @@ protected:
         SharedPtr<InvalidCertificateHandler> invalidCertHandler = new AcceptCertificateHandler(false);
         Context::Params sslParams;
         Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslParams);
-        SSLManager::instance().initializeClient(0, invalidCertHandler, sslContext);
+        SSLManager::instance().initializeClient(nullptr, invalidCertHandler, sslContext);
 
         HTTPSClientSession cs(_uri.getHost(), _uri.getPort());
 #else
diff --git a/tools/map.cpp b/tools/map.cpp
index c455a14..83043a1 100644
--- a/tools/map.cpp
+++ b/tools/map.cpp
@@ -85,7 +85,7 @@ static void total_smaps(unsigned proc_id, const char *file, const char *cmdline)
     unsigned long long smap_value;
     char smap_key[MAP_SIZE];
 
-    if ((file_pointer = fopen(file, "r")) == NULL)
+    if ((file_pointer = fopen(file, "r")) == nullptr)
         error(EXIT_FAILURE, errno, "%s", file);
 
     while (fgets(buffer, sizeof(buffer), file_pointer))
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
 
         if (*dir_proc->d_name > '0' && *dir_proc->d_name <= '9')
         {
-            pid_proc = strtoul(dir_proc->d_name, NULL, 10);
+            pid_proc = strtoul(dir_proc->d_name, nullptr, 10);
             snprintf(path_proc, sizeof(path_proc), "/proc/%s/%s", dir_proc->d_name, "cmdline");
             if (read_buffer(cmdline, sizeof(cmdline), path_proc, ' ') &&
                 strstr(cmdline, argv[1]) &&
diff --git a/tools/mount.cpp b/tools/mount.cpp
index b8d87d3..89df406 100644
--- a/tools/mount.cpp
+++ b/tools/mount.cpp
@@ -22,14 +22,14 @@ int main(int argc, char **argv)
     if (argc < 3)
         return 1;
 
-    int retval = mount (argv[1], argv[2], 0, MS_BIND, 0);
+    int retval = mount (argv[1], argv[2], nullptr, MS_BIND, nullptr);
     if (retval)
         return retval;
 
     // apparently this has to be done in a 2nd pass.
-    return mount(argv[1], argv[2], 0,
+    return mount(argv[1], argv[2], nullptr,
                  (MS_BIND | MS_REMOUNT | MS_NOATIME | MS_NODEV |
-                  MS_NOSUID | MS_RDONLY  | MS_SILENT), 0);
+                  MS_NOSUID | MS_RDONLY  | MS_SILENT), nullptr);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list