diff --git a/ReleaseNotes.md b/ReleaseNotes.md index ee72a71efe719c1dfcf9a41dd47482231ba86f5a..e05eff48878e1868ea664da0a709303729c82a3e 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -10,6 +10,7 @@ - cta/CTA#1160 - Fix DrainingToDisk stale status in case if there is DiskWriteThreadPool thread left - cta/operations#708 - Fix "Should run cleaner but VID is missing. Putting the drive down" - cta/CTA#1197 - Return code from `cta-catalogue-schema-verify` should indicate if the schema is in UPGRADING state +- cta/CTA#1206 - Change NULL for nullptr ### Building and Packaging ### Catalogue Schema diff --git a/catalogue/CreateAdminUserCmdLineArgsTest.cpp b/catalogue/CreateAdminUserCmdLineArgsTest.cpp index 175017b67eeffe9101d3571babff586f6d001c8a..79fc5e4c15e0592d1d0c7e3e34990df9edf3f002 100644 --- a/catalogue/CreateAdminUserCmdLineArgsTest.cpp +++ b/catalogue/CreateAdminUserCmdLineArgsTest.cpp @@ -28,7 +28,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -74,7 +74,7 @@ TEST_F(cta_catalogue_CreateAdminUserCmdLineArgsTest, help_short) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-admin-user-create"); args->argv[1] = dupString("-h"); - args->argv[2] = NULL; + args->argv[2] = nullptr; CreateAdminUserCmdLineArgs cmdLine(args->argc, args->argv); @@ -93,7 +93,7 @@ TEST_F(cta_catalogue_CreateAdminUserCmdLineArgsTest, help_long) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-admin-user-create"); args->argv[1] = dupString("--help"); - args->argv[2] = NULL; + args->argv[2] = nullptr; CreateAdminUserCmdLineArgs cmdLine(args->argc, args->argv); @@ -116,7 +116,7 @@ TEST_F(cta_catalogue_CreateAdminUserCmdLineArgsTest, username_short) { args->argv[3] = dupString("adminUsername"); args->argv[4] = dupString("-m"); args->argv[5] = dupString("comment"); - args->argv[6] = NULL; + args->argv[6] = nullptr; CreateAdminUserCmdLineArgs cmdLine(args->argc, args->argv); @@ -139,7 +139,7 @@ TEST_F(cta_catalogue_CreateAdminUserCmdLineArgsTest, username_long) { args->argv[3] = dupString("adminUsername"); args->argv[4] = dupString("--comment"); args->argv[5] = dupString("comment"); - args->argv[6] = NULL; + args->argv[6] = nullptr; CreateAdminUserCmdLineArgs cmdLine(args->argc, args->argv); diff --git a/catalogue/CreateSchemaCmdLineArgsTest.cpp b/catalogue/CreateSchemaCmdLineArgsTest.cpp index 5542fc21eb2c31d0869ca86b1933e7d95b7cb613..c85a0aeff6b026fcc30d51b95f7407de45b9b642 100644 --- a/catalogue/CreateSchemaCmdLineArgsTest.cpp +++ b/catalogue/CreateSchemaCmdLineArgsTest.cpp @@ -29,7 +29,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_catalogue_CreateSchemaCmdLineArgsTest, help_short) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-create"); args->argv[1] = dupString("-h"); - args->argv[2] = NULL; + args->argv[2] = nullptr; CreateSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -92,7 +92,7 @@ TEST_F(cta_catalogue_CreateSchemaCmdLineArgsTest, help_long) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-create"); args->argv[1] = dupString("--help"); - args->argv[2] = NULL; + args->argv[2] = nullptr; CreateSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -111,7 +111,7 @@ TEST_F(cta_catalogue_CreateSchemaCmdLineArgsTest, version_short) { args->argv[1] = dupString("dbConfigPath"); args->argv[2] = dupString("-v"); args->argv[3] = dupString("4.5"); - args->argv[4] = NULL; + args->argv[4] = nullptr; CreateSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -130,7 +130,7 @@ TEST_F(cta_catalogue_CreateSchemaCmdLineArgsTest, version_long) { args->argv[1] = dupString("dbConfigPath"); args->argv[2] = dupString("--version"); args->argv[3] = dupString("4.5"); - args->argv[4] = NULL; + args->argv[4] = nullptr; CreateSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -148,7 +148,7 @@ TEST_F(cta_catalogue_CreateSchemaCmdLineArgsTest, dbConfigPath) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-create"); args->argv[1] = dupString("dbConfigPath"); - args->argv[2] = NULL; + args->argv[2] = nullptr; CreateSchemaCmdLineArgs cmdLine(args->argc, args->argv); diff --git a/catalogue/DropSchemaCmdLineArgsTest.cpp b/catalogue/DropSchemaCmdLineArgsTest.cpp index a9a6dc11953919da70203cc903e7383d80069a6b..320d125a8bd2a18a2a68ca154e8ec9684f9b7789 100644 --- a/catalogue/DropSchemaCmdLineArgsTest.cpp +++ b/catalogue/DropSchemaCmdLineArgsTest.cpp @@ -29,7 +29,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_catalogue_DropSchemaCmdLineArgsTest, help_short) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-drop"); args->argv[1] = dupString("-h"); - args->argv[2] = NULL; + args->argv[2] = nullptr; DropSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -92,7 +92,7 @@ TEST_F(cta_catalogue_DropSchemaCmdLineArgsTest, help_long) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-drop"); args->argv[1] = dupString("--help"); - args->argv[2] = NULL; + args->argv[2] = nullptr; DropSchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -109,7 +109,7 @@ TEST_F(cta_catalogue_DropSchemaCmdLineArgsTest, dbConfigPath) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-drop"); args->argv[1] = dupString("dbConfigPath"); - args->argv[2] = NULL; + args->argv[2] = nullptr; DropSchemaCmdLineArgs cmdLine(args->argc, args->argv); diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index cb57cba49a46552af6a8e7c4a3522ee70eb406fa..5aae996927e883a0704a080af6fab6e19d947ef1 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -269,7 +269,7 @@ public: std::optional<common::dataStructures::TapeDrive> getTapeDrive(const std::string &tapeDriveName) const { if (m_tapeDriveStatus.driveName != "") return m_tapeDriveStatus; common::dataStructures::TapeDrive tapeDriveStatus; - const time_t reportTime = time(NULL); + const time_t reportTime = time(nullptr); tapeDriveStatus.driveName = tapeDriveName; tapeDriveStatus.host = "Dummy_Host"; @@ -285,7 +285,7 @@ public: tapeDriveStatus.diskSystemName = "Dummy_System"; tapeDriveStatus.reservedBytes = 0; tapeDriveStatus.reservationSessionId = 0; - + return tapeDriveStatus; } @@ -351,12 +351,12 @@ public: tdStatus.value().reservationSessionId = mountId; tdStatus.value().reservedBytes = 0; } - + if (tdStatus.value().reservationSessionId != mountId) { tdStatus.value().reservationSessionId = mountId; tdStatus.value().reservedBytes = 0; } - + tdStatus.value().diskSystemName = diskSpaceReservation.begin()->first; tdStatus.value().reservedBytes.value() += diskSpaceReservation.begin()->second; modifyTapeDrive(tdStatus.value()); @@ -373,7 +373,7 @@ public: lc.log(log::DEBUG, "In RetrieveMount::releaseDiskSpace(): reservation release request."); auto tdStatus = getTapeDrive(driveName); - + if (!tdStatus) return; if (!tdStatus.value().reservationSessionId) { return; @@ -404,7 +404,7 @@ public: void createDiskInstanceSpace(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &diskInstance, const std::string &freeSpaceQueryURL, const uint64_t refreshInterval, const std::string &comment) override { m_diskInstanceSpaces[name] = {name, diskInstance, freeSpaceQueryURL, refreshInterval, 0, 0, comment, common::dataStructures::EntryLog(), common::dataStructures::EntryLog()}; } - + void createDiskSystem(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &diskInstanceName, const std::string &diskInstanceSpaceName, const std::string &fileRegexp, const uint64_t targetedFreeSpace, const time_t sleepTime, const std::string &comment) override { m_diskSystemList.push_back({name, m_diskInstanceSpaces.at(diskInstanceSpaceName), fileRegexp, targetedFreeSpace, sleepTime, common::dataStructures::EntryLog(), common::dataStructures::EntryLog{}, comment}); } diff --git a/catalogue/PollDatabaseCmdLineArgsTest.cpp b/catalogue/PollDatabaseCmdLineArgsTest.cpp index 89558abbe105eecc981e252439a8db1c36228746..59a9dd1c28aaa691917acc4c254ae36a200a610a 100644 --- a/catalogue/PollDatabaseCmdLineArgsTest.cpp +++ b/catalogue/PollDatabaseCmdLineArgsTest.cpp @@ -29,7 +29,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_catalogue_PollDatabaseCmdLineArgsTest, help_short) { args->argv = new char *[3]; args->argv[0] = dupString("cta-database-poll"); args->argv[1] = dupString("-h"); - args->argv[2] = NULL; + args->argv[2] = nullptr; PollDatabaseCmdLineArgs cmdLine(args->argc, args->argv); @@ -93,7 +93,7 @@ TEST_F(cta_catalogue_PollDatabaseCmdLineArgsTest, help_long) { args->argv = new char *[3]; args->argv[0] = dupString("cta-database-poll"); args->argv[1] = dupString("--help"); - args->argv[2] = NULL; + args->argv[2] = nullptr; PollDatabaseCmdLineArgs cmdLine(args->argc, args->argv); @@ -112,7 +112,7 @@ TEST_F(cta_catalogue_PollDatabaseCmdLineArgsTest, all_args) { args->argv[0] = dupString("cta-database-poll"); args->argv[1] = dupString("dbConfigPath"); args->argv[2] = dupString("1234"); - args->argv[3] = NULL; + args->argv[3] = nullptr; PollDatabaseCmdLineArgs cmdLine(args->argc, args->argv); diff --git a/catalogue/VerifySchemaCmdLineArgsTest.cpp b/catalogue/VerifySchemaCmdLineArgsTest.cpp index 18ffe5bfe7a787bcae716cda2a98997b759e93ce..4ee173388dcc15200b75dc111cf6917c69433a46 100644 --- a/catalogue/VerifySchemaCmdLineArgsTest.cpp +++ b/catalogue/VerifySchemaCmdLineArgsTest.cpp @@ -29,7 +29,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_catalogue_VerifySchemaCmdLineArgsTest, help_short) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-verify"); args->argv[1] = dupString("-h"); - args->argv[2] = NULL; + args->argv[2] = nullptr; VerifySchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -92,7 +92,7 @@ TEST_F(cta_catalogue_VerifySchemaCmdLineArgsTest, help_long) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-verify"); args->argv[1] = dupString("--help"); - args->argv[2] = NULL; + args->argv[2] = nullptr; VerifySchemaCmdLineArgs cmdLine(args->argc, args->argv); @@ -109,7 +109,7 @@ TEST_F(cta_catalogue_VerifySchemaCmdLineArgsTest, dbConfigPath) { args->argv = new char *[3]; args->argv[0] = dupString("cta-catalogue-schema-verify"); args->argv[1] = dupString("dbConfigPath"); - args->argv[2] = NULL; + args->argv[2] = nullptr; VerifySchemaCmdLineArgs cmdLine(args->argc, args->argv); diff --git a/cmdline/restore_files/RestoreFilesCmdLineArgs.cpp b/cmdline/restore_files/RestoreFilesCmdLineArgs.cpp index 9ae2b9c54f465487611731639e8eaf8da6241ee5..889f26f864cb50ea7a1bcc40cbffdf339e883dc4 100644 --- a/cmdline/restore_files/RestoreFilesCmdLineArgs.cpp +++ b/cmdline/restore_files/RestoreFilesCmdLineArgs.cpp @@ -35,17 +35,17 @@ namespace admin{ //------------------------------------------------------------------------------ RestoreFilesCmdLineArgs::RestoreFilesCmdLineArgs(const int argc, char *const *const argv): m_help(false), m_debug(false) { - + static struct option longopts[] = { - {"id", required_argument, NULL, 'I'}, - {"instance", required_argument, NULL, 'i'}, - {"fxid", required_argument, NULL, 'f'}, - {"fxidfile", required_argument, NULL, 'F'}, - {"vid", required_argument, NULL, 'v'}, - {"copynb", required_argument, NULL, 'c'}, - {"help", no_argument, NULL, 'h'}, - {"debug", no_argument, NULL, 'd'}, - {NULL, 0, NULL, 0} + {"id", required_argument, nullptr, 'I'}, + {"instance", required_argument, nullptr, 'i'}, + {"fxid", required_argument, nullptr, 'f'}, + {"fxidfile", required_argument, nullptr, 'F'}, + {"vid", required_argument, nullptr, 'v'}, + {"copynb", required_argument, nullptr, 'c'}, + {"help", no_argument, nullptr, 'h'}, + {"debug", no_argument, nullptr, 'd'}, + {nullptr, 0, nullptr, 0} }; opterr = 0; @@ -100,7 +100,7 @@ m_help(false), m_debug(false) { } case 'h': { - m_help = true; + m_help = true; break; } case 'd': @@ -161,7 +161,7 @@ void RestoreFilesCmdLineArgs::readFidListFromFile(const std::string &filename, s ss >> item; // skip blank lines or lines consisting only of whitespace if(item.empty()) continue; - + // Special handling for file id lists. The output from "eos find --fid <fid> /path" is: // path=/path fid=<fid> // We discard everything except the list of fids. <fid> is a zero-padded hexadecimal number, @@ -190,4 +190,4 @@ void RestoreFilesCmdLineArgs::printUsage(std::ostream &os) { } } // namespace admin -} // namespace cta \ No newline at end of file +} // namespace cta diff --git a/common/Configuration.cpp b/common/Configuration.cpp index e51a08affd31acca8e911e746ec5b843faf55355..f88d3b8d827e77158b12356b05a5d7ffd884f7b3 100644 --- a/common/Configuration.cpp +++ b/common/Configuration.cpp @@ -30,7 +30,7 @@ cta::common::Configuration::Configuration(const std::string& fileName) : m_fileName(fileName), m_lastUpdateTime(0) { // create internal r/w lock - int rc = pthread_rwlock_init(&m_lock, NULL); + int rc = pthread_rwlock_init(&m_lock, nullptr); if (0 != rc) { cta::exception::Errnum e(rc); e.getMessage() << "CastorConfiguration constructor Failed" @@ -47,7 +47,7 @@ cta::common::Configuration::Configuration( m_fileName(other.m_fileName), m_lastUpdateTime(other.m_lastUpdateTime), m_config(other.m_config) { // create a new internal r/w lock - int rc = pthread_rwlock_init(&m_lock, NULL); + int rc = pthread_rwlock_init(&m_lock, nullptr); if (0 != rc) { cta::exception::Errnum e(rc); e.getMessage() << "CastorConfiguration copy constructor failed" @@ -75,7 +75,7 @@ cta::common::Configuration & m_lastUpdateTime = other.m_lastUpdateTime; m_config = other.m_config; // create a new internal r/w lock - int rc = pthread_rwlock_init(&m_lock, NULL); + int rc = pthread_rwlock_init(&m_lock, nullptr); if (0 != rc) { cta::exception::Errnum e(rc); e.getMessage() << "Assignment operator of CastorConfiguration object failed" @@ -111,7 +111,7 @@ const std::string& cta::common::Configuration::getConfEntString( if (catIt->second.end() != entIt) { // release the lock pthread_rwlock_unlock(&m_lock); - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), @@ -123,7 +123,7 @@ const std::string& cta::common::Configuration::getConfEntString( } } // no entry found - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), @@ -137,7 +137,7 @@ const std::string& cta::common::Configuration::getConfEntString( // exception caught : Unlock and return default pthread_rwlock_unlock(&m_lock); // log the exception - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), @@ -189,7 +189,7 @@ const std::string& cta::common::Configuration::getConfEntString( throw e; } - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), diff --git a/common/Configuration.hpp b/common/Configuration.hpp index 5de937b8e6c98ae833c9d79c2ea0cb5158347c3e..347de4c91e354c04dc55dcbad3757e34f1849801 100644 --- a/common/Configuration.hpp +++ b/common/Configuration.hpp @@ -85,11 +85,11 @@ namespace cta { namespace common { * @param key the key of the entry * @param defaultValue the value to be returned if the configuration entry * is not in the configuration file - * @param log pointer to NULL or an optional logger object + * @param log pointer to nullptr or an optional logger object */ const std::string& getConfEntString(const std::string &category, const std::string &key, const std::string &defaultValue, - cta::log::Logger *const log = NULL); + cta::log::Logger *const log = nullptr); /** * Retrieves a configuration entry. @@ -103,10 +103,10 @@ namespace cta { namespace common { * * @param category the category of the entry * @param key the key of the entry - * @param log pointer to NULL or an optional logger object + * @param log pointer to nullptr or an optional logger object */ const std::string& getConfEntString(const std::string &category, - const std::string &key, cta::log::Logger *const log = NULL); + const std::string &key, cta::log::Logger *const log = nullptr); /** * Retrieves a configuration entry as an integer. @@ -120,17 +120,17 @@ namespace cta { namespace common { * @param name category of the configuration parameter * @param defaultValue the value to be returned if the configuration entry * is not in the configuration file - * @param log pointer to NULL or an optional logger object + * @param log pointer to nullptr or an optional logger object * @return the integer value */ template<typename T> T getConfEntInt(const std::string &category, const std::string &key, const T defaultValue, - cta::log::Logger *const log = NULL) { + cta::log::Logger *const log = nullptr) { std::string strValue; try { strValue = getConfEntString(category, key); } catch(cta::exception::Exception &ex) { - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), @@ -155,7 +155,7 @@ namespace cta { namespace common { ss << strValue.c_str(); ss >> value; - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), @@ -176,11 +176,11 @@ namespace cta { namespace common { * * @param category category of the configuration parameter * @param name category of the configuration parameter - * @param log pointer to NULL or an optional logger object + * @param log pointer to nullptr or an optional logger object * @return the integer value */ template<typename T> T getConfEntInt(const std::string &category, - const std::string &key, cta::log::Logger *const log = NULL) { + const std::string &key, cta::log::Logger *const log = nullptr) { const std::string strValue = getConfEntString(category, key); if (!utils::isValidUInt(strValue.c_str())) { @@ -196,7 +196,7 @@ namespace cta { namespace common { ss << strValue.c_str(); ss >> value; - if(NULL != log) { + if(nullptr != log) { std::list<cta::log::Param> params = { cta::log::Param("category", category), cta::log::Param("key", key), diff --git a/common/SmartArrayPtr.hpp b/common/SmartArrayPtr.hpp index 8363986bf8f9624ef6178e0359a7a1c5c644ec7b..90ad36bf3e8cf5f691ab76b9d4ea925a1c46c1ba 100644 --- a/common/SmartArrayPtr.hpp +++ b/common/SmartArrayPtr.hpp @@ -35,7 +35,7 @@ public: /** * Constructor. */ - SmartArrayPtr() throw(): m_arrayPtr(NULL) { + SmartArrayPtr() throw(): m_arrayPtr(nullptr) { } /** @@ -53,15 +53,15 @@ public: * then it will be deleted using delete[]. * * @param arrayPtr The pointer to be owned. If no pointer is specified then - * the default value of NULL is used. In this default case the smart pointer + * the default value of nullptr is used. In this default case the smart pointer * will not own a pointer after the reset() method returns. */ - void reset(T *const arrayPtr = NULL) throw() { + void reset(T *const arrayPtr = nullptr) throw() { // If the new pointer is not the one already owned if(arrayPtr != m_arrayPtr) { // If this smart pointer still owns a pointer then call delete[] on it - if(m_arrayPtr != NULL) { + if(m_arrayPtr != nullptr) { delete[] m_arrayPtr; } @@ -89,16 +89,16 @@ public: /** * Destructor. * - * Resets this smart pointer with the default value of NULL. + * Resets this smart pointer with the default value of nullptr. */ ~SmartArrayPtr() throw() { reset(); } /** - * Returns the owned pointer or NULL if this smart pointer does not own one. + * Returns the owned pointer or nullptr if this smart pointer does not own one. * - * @return The owned pointer or NULL if this smart pointer does not own one. + * @return The owned pointer or nullptr if this smart pointer does not own one. */ T *get() const throw() { return m_arrayPtr; @@ -111,16 +111,16 @@ public: */ T *release() { // If this smart pointer does not own a pointer - if(NULL == m_arrayPtr) { + if(nullptr == m_arrayPtr) { cta::exception::NotAnOwner ex; ex.getMessage() << "Smart pointer does not own a pointer"; throw(ex); } - // Assigning NULL to m_arrayPtr indicates this smart pointer does not own a + // Assigning nullptr to m_arrayPtr indicates this smart pointer does not own a // pointer T *const tmpArrayPtr = m_arrayPtr; - m_arrayPtr = NULL; + m_arrayPtr = nullptr; return tmpArrayPtr; } @@ -134,9 +134,9 @@ public: private: /** - * The owned pointer. A value of NULL means this smart pointer does not own + * The owned pointer. A value of nullptr means this smart pointer does not own * a pointer. - */ + */ T *m_arrayPtr; /** @@ -150,4 +150,3 @@ private: }; // class SmartArrayPtr } // namespace cta - diff --git a/common/SmartFILEPtr.cpp b/common/SmartFILEPtr.cpp index c8150378a49af5d5d8e15b3b0214728d0d23b5a7..65f1e7511ff814bd723e66d8be7f62892b208142 100644 --- a/common/SmartFILEPtr.cpp +++ b/common/SmartFILEPtr.cpp @@ -21,12 +21,12 @@ #include <unistd.h> namespace cta { - + //----------------------------------------------------------------------------- // constructor //----------------------------------------------------------------------------- SmartFILEPtr::SmartFILEPtr() throw() : - m_file(NULL) { + m_file(nullptr) { } //----------------------------------------------------------------------------- @@ -44,7 +44,7 @@ void SmartFILEPtr::reset(FILE *const file) throw() { if(file != m_file) { // If this smart pointer still owns a pointer, then fclose it - if(m_file != NULL) { + if(m_file != nullptr) { fclose(m_file); } @@ -81,7 +81,7 @@ FILE *SmartFILEPtr::get() const throw() { //----------------------------------------------------------------------------- FILE *SmartFILEPtr::release() { // If this smart pointer does not own a pointer - if(NULL == m_file) { + if(nullptr == m_file) { cta::exception::NotAnOwner ex; ex.getMessage() << "Smart pointer does not own a FILE pointer"; throw ex; @@ -89,8 +89,8 @@ FILE *SmartFILEPtr::release() { FILE *const tmp = m_file; - // A NULL value indicates this smart pointer does not own a pointer - m_file = NULL; + // A nullptr value indicates this smart pointer does not own a pointer + m_file = nullptr; return tmp; } diff --git a/common/SmartFILEPtr.hpp b/common/SmartFILEPtr.hpp index 0049e429d1d4183384ad8f03013e0a461b62016a..958782fa02cbfbe2ecea1b746c1e37dec4173d28 100644 --- a/common/SmartFILEPtr.hpp +++ b/common/SmartFILEPtr.hpp @@ -49,11 +49,11 @@ public: * owned FILE pointer if there is one and it is not the same as the one * specified. * - * @param file The FILE pointer to be owned, defaults to NULL if not - * specified, where NULL means this smart pointer will not own a + * @param file The FILE pointer to be owned, defaults to nullptr if not + * specified, where nullptr means this smart pointer will not own a * pointer after the reset() method returns. */ - void reset(FILE *const file = NULL) throw(); + void reset(FILE *const file = nullptr) throw(); /** * SmartFILEPtr assignment operator. @@ -76,7 +76,7 @@ public: ~SmartFILEPtr() throw(); /** - * Returns the owned pointer or NULL if this smart pointer does not own one. + * Returns the owned pointer or nullptr if this smart pointer does not own one. * * @return The owned FILE pointer. */ @@ -92,9 +92,9 @@ public: private: /** - * The owned pointer. A value of NULL means this smart pointer does not own + * The owned pointer. A value of nullptr means this smart pointer does not own * a pointer. - */ + */ FILE *m_file; /** @@ -107,4 +107,3 @@ private: }; // class SmartFILEPtr } // namespace cta - diff --git a/common/SmartFd.cpp b/common/SmartFd.cpp index 4cfc8823943574d689263a748ef6c780b5499639..062e4b070f63fa1651d9d5281afdf5ab0b34a95a 100644 --- a/common/SmartFd.cpp +++ b/common/SmartFd.cpp @@ -24,14 +24,14 @@ // constructor //----------------------------------------------------------------------------- cta::SmartFd::SmartFd() throw(): - m_fd(-1), m_closedCallback(NULL) { + m_fd(-1), m_closedCallback(nullptr) { } //----------------------------------------------------------------------------- // constructor //----------------------------------------------------------------------------- cta::SmartFd::SmartFd(const int fd) throw(): - m_fd(fd), m_closedCallback(NULL) { + m_fd(fd), m_closedCallback(nullptr) { } //----------------------------------------------------------------------------- diff --git a/common/SmartFd.hpp b/common/SmartFd.hpp index 232dd4435b615968651e38719a0ebd4892a79a14..1b074d5f81a50f484ddbcf66f73427b829c79247 100644 --- a/common/SmartFd.hpp +++ b/common/SmartFd.hpp @@ -58,7 +58,7 @@ public: * Sets the function to be called back by the SmartFd immediately after * the SmartFd has closed the file-descriptor it owns. * - * Setting the callback function to NULL means that no function will be + * Setting the callback function to nullptr means that no function will be * called. * * Please note any exception thrown by the callback function will be diff --git a/common/checksum/ChecksumBlob.cpp b/common/checksum/ChecksumBlob.cpp index 8087672160ad368920ec38fe3695d8c92f6a5f19..88bbfa34bf37f0f3ef5e2e6aea7a110d63233cfc 100644 --- a/common/checksum/ChecksumBlob.cpp +++ b/common/checksum/ChecksumBlob.cpp @@ -112,7 +112,7 @@ void ChecksumBlob::deserialize(const std::string &bytearray) { void ChecksumBlob::deserializeOrSetAdler32(const std::string &bytearray, uint32_t adler32) { common::ChecksumBlob p_csb; - // A NULL value in the CHECKSUM_BLOB column will return an empty bytearray. If the bytearray is empty + // A nullptr value in the CHECKSUM_BLOB column will return an empty bytearray. If the bytearray is empty // or otherwise invalid, default to using the contents of the CHECKSUM_ADLER32 column. if(!bytearray.empty() && p_csb.ParseFromString(bytearray)) { ProtobufToChecksumBlob(p_csb, *this); diff --git a/common/dataStructures/TapeDrive.hpp b/common/dataStructures/TapeDrive.hpp index dd563802b48e39b96608b0984218d3671815140a..7774d23283168593c50c69a56d01dd4aaa672e91 100644 --- a/common/dataStructures/TapeDrive.hpp +++ b/common/dataStructures/TapeDrive.hpp @@ -96,7 +96,7 @@ struct TapeDrive { std::optional<uint64_t> currentPriority; std::optional<std::string> currentActivity; std::optional<std::string> currentTapePool; - MountType nextMountType; // defaults to NO_MOUNT. This can't be optional, as we have a NOT NULL constraint in the DB. + MountType nextMountType; // defaults to NO_MOUNT. This can't be optional, as we have a NOT nullptr constraint in the DB. std::optional<std::string> nextVid; std::optional<std::string> nextTapePool; std::optional<uint64_t> nextPriority; diff --git a/common/exception/Backtrace.cpp b/common/exception/Backtrace.cpp index b81561f2a035c956ba768c552622dc0ed2e1af2d..b0fb1319532b7f32161bfe4d6d49442e0a11ba74 100644 --- a/common/exception/Backtrace.cpp +++ b/common/exception/Backtrace.cpp @@ -33,11 +33,11 @@ namespace cta { private: class mutex { public: - mutex() { pthread_mutex_init(&m_mutex, NULL); } + mutex() { pthread_mutex_init(&m_mutex, nullptr); } void lock() { pthread_mutex_lock(&m_mutex); } void unlock() { pthread_mutex_unlock(&m_mutex); } private: - pthread_mutex_t m_mutex; + pthread_mutex_t m_mutex; }; mutex m_mutex; bfd* m_abfd; @@ -52,7 +52,7 @@ namespace cta { // This code is compiled only in debug mode (where COLLECTEXTRABACKTRACEINFOS will be defined) // as it's pretty heavy cta::exception::bfdContext::bfdContext(): -m_abfd(NULL), m_syms(NULL), m_text(NULL) +m_abfd(nullptr), m_syms(nullptr), m_text(nullptr) { char ename[1024]; int l = readlink("/proc/self/exe",ename,sizeof(ename)); @@ -74,7 +74,7 @@ m_abfd(NULL), m_syms(NULL), m_text(NULL) cta::exception::bfdContext::~bfdContext() { free (m_syms); /* According the bfd documentation, closing the bfd frees everything */ - m_text=NULL; + m_text=nullptr; bfd_close(m_abfd); } @@ -91,10 +91,10 @@ std::string cta::exception::bfdContext::collectExtraInfos(const std::string& add const char *file; const char *func; unsigned line; - if (bfd_find_nearest_line(m_abfd, m_text, m_syms, offset, &file, &func, &line) + if (bfd_find_nearest_line(m_abfd, m_text, m_syms, offset, &file, &func, &line) && file) { int status(-1); - char * demangledFunc = abi::__cxa_demangle(func, NULL, NULL, &status); + char * demangledFunc = abi::__cxa_demangle(func, nullptr, nullptr, &status); result << "at " << file << ":" << line << " (" << address << ")"; free (demangledFunc); } @@ -114,7 +114,7 @@ namespace cta { cta::exception::Backtrace::Backtrace(bool fake): m_trace() { if (fake) return; void * array[200]; - g_lock.lock(); + g_lock.lock(); size_t depth = ::backtrace(array, sizeof(array)/sizeof(void*)); char ** strings = ::backtrace_symbols(array, depth); @@ -133,7 +133,7 @@ cta::exception::Backtrace::Backtrace(bool fake): m_trace() { after = line.substr(line.find("+"), line.find("[")-line.find("+")+1); addr = line.substr(line.find("[")+1, line.find("]")-line.find("[")-1); int status(-1); - char * demangled = abi::__cxa_demangle(theFunc.c_str(), NULL, NULL, &status); + char * demangled = abi::__cxa_demangle(theFunc.c_str(), nullptr, nullptr, &status); if (0 == status) { m_trace += before; m_trace += demangled; @@ -152,7 +152,7 @@ cta::exception::Backtrace::Backtrace(bool fake): m_trace() { } else { m_trace += strings[i]; m_trace += "\n"; - } + } } free (strings); } diff --git a/common/exception/Backtrace.hpp b/common/exception/Backtrace.hpp index 7298de2a0aab639368e08bb01f1e3dd109918cfc..1b25d4275ba609806c8a6c6bb360aae91b198a28 100644 --- a/common/exception/Backtrace.hpp +++ b/common/exception/Backtrace.hpp @@ -36,11 +36,11 @@ namespace cta { */ class mutex { public: - mutex() { pthread_mutex_init(&m_mutex, NULL); } + mutex() { pthread_mutex_init(&m_mutex, nullptr); } void lock() { pthread_mutex_lock(&m_mutex); } void unlock() { pthread_mutex_unlock(&m_mutex); } private: - pthread_mutex_t m_mutex; + pthread_mutex_t m_mutex; }; static mutex g_lock; }; diff --git a/common/exception/Errnum.cpp b/common/exception/Errnum.cpp index 67caef7625c41ecd1b7a27cc87df02ef1ed3a036..62134701eac67a07528e48a894c4d3dcf0a86e5d 100644 --- a/common/exception/Errnum.cpp +++ b/common/exception/Errnum.cpp @@ -55,7 +55,7 @@ void Errnum::throwOnZero(const int status, const std::string &context) { } void Errnum::throwOnNull(const void *const f, const std::string &context) { - if (NULL == f) throw Errnum(context); + if (nullptr == f) throw Errnum(context); } void Errnum::throwOnNegative(const int ret, const std::string &context) { diff --git a/common/exception/ExceptionTest.cpp b/common/exception/ExceptionTest.cpp index 41a1e5de4fcfc70fd5992ff68b730de4d77cc6a3..bf209f8449a751d56c0a48810de8d0b71a0eb700 100644 --- a/common/exception/ExceptionTest.cpp +++ b/common/exception/ExceptionTest.cpp @@ -29,18 +29,18 @@ namespace unitTests { void f2(); Nested(); }; - + /* Prevent inlining: it makes this test fail! */ void __attribute__((noinline)) Nested::f1() { throw cta::exception::Exception("Throwing in Nested's constructor"); } - + /* Prevent inlining: it makes this test fail! * Even with that, f2 does not show up in the trace */ void __attribute__((noinline)) Nested::f2() { f1(); } - + /* Prevent inlining: it makes this test fail! */ __attribute__((noinline)) Nested::Nested() { f2(); @@ -58,7 +58,7 @@ namespace unitTests { ASSERT_NE(std::string::npos, fullWhat.find("Nested::f1")); } } - + TEST(cta_exceptions, stacktrace_in_std_exception) { try { Nested x; @@ -68,7 +68,7 @@ namespace unitTests { ASSERT_NE(std::string::npos, fullWhat.find("Throwing in Nested's constructor")); } } - + TEST(cta_exceptions, errnum_throwing) { /* Mickey Mouse test as we had trouble which throwing Errnum (with errno=ENOENT)*/ errno = ENOENT; @@ -85,7 +85,7 @@ namespace unitTests { ASSERT_NO_THROW(cta::exception::Errnum::throwOnReturnedErrno(0, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnReturnedErrno(ENOSPC, "Context"), cta::exception::Errnum); - + ASSERT_NO_THROW(cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([](){ return 0; }, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([](){ return ENOSPC; }, "Context"), cta::exception::Errnum); @@ -93,36 +93,36 @@ namespace unitTests { cta::exception::Errnum); ASSERT_THROW(cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([](){ throw std::exception(); return 0; }, "Context"), cta::exception::Exception); - - + + /* throwOnNonZero */ errno = ENOENT; ASSERT_NO_THROW(cta::exception::Errnum::throwOnNonZero(0, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnNonZero(-1, "Context"), cta::exception::Errnum); - + /* throwOnMinusOne */ errno = ENOENT; ASSERT_NO_THROW(cta::exception::Errnum::throwOnMinusOne(0, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnMinusOne(-1, "Context"), cta::exception::Errnum); - + /* throwOnNegative */ errno = ENOENT; ASSERT_NO_THROW(cta::exception::Errnum::throwOnNegative(0, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnNegative(-1, "Context"), - cta::exception::Errnum); + cta::exception::Errnum); /* throwOnNull */ errno = ENOENT; ASSERT_NO_THROW(cta::exception::Errnum::throwOnNull(this, "Context")); - ASSERT_THROW(cta::exception::Errnum::throwOnNull(NULL, "Context"), + ASSERT_THROW(cta::exception::Errnum::throwOnNull(nullptr, "Context"), cta::exception::Errnum); /* throwOnZero */ errno = ENOENT; ASSERT_NO_THROW(cta::exception::Errnum::throwOnZero(1, "Context")); ASSERT_THROW(cta::exception::Errnum::throwOnZero(0, "Context"), - cta::exception::Errnum); + cta::exception::Errnum); } } diff --git a/common/log/Logger.cpp b/common/log/Logger.cpp index e56f009c966f01a0df4ddd986b6ed865866f921b..527bdb97fa74ffce207681a95365dba4a4eecc94 100644 --- a/common/log/Logger.cpp +++ b/common/log/Logger.cpp @@ -47,7 +47,7 @@ Logger::~Logger() { } //----------------------------------------------------------------------------- -// operator() +// operator() //----------------------------------------------------------------------------- void Logger::operator() ( const int priority, @@ -56,7 +56,7 @@ void Logger::operator() ( const std::string rawParams; struct timeval timeStamp; - gettimeofday(&timeStamp, NULL); + gettimeofday(&timeStamp, nullptr); const int pid = getpid(); // Ignore messages whose priority is not of interest @@ -89,14 +89,14 @@ std::string Logger::cleanString(const std::string &s, const bool replaceUnderscores) { // Trim both left and right white-space std::string result = utils::trimString(s); - + for (std::string::iterator it = result.begin(); it != result.end(); ++it) { // Replace double quote with single quote if ('"' == *it) { *it = '\''; } - + // Replace newline and tab with a space if ('\t' == *it || '\n' == *it) { *it = ' '; diff --git a/common/log/log.cpp b/common/log/log.cpp index ae281b9cfe379ee5173d0f0a7a1a9bb0dfc23a3b..3ffd852fba1c1b0fbb60ae4c6f88d267a165d8c6 100644 --- a/common/log/log.cpp +++ b/common/log/log.cpp @@ -21,7 +21,7 @@ /** * The logger to be used by the CASTOR logging systsem. */ -static cta::log::Logger *s_logger = NULL; +static cta::log::Logger *s_logger = nullptr; //------------------------------------------------------------------------------ // init @@ -40,14 +40,14 @@ void cta::log::init(cta::log::Logger *logger) { //------------------------------------------------------------------------------ void cta::log::shutdown() { delete s_logger; - s_logger = NULL; + s_logger = nullptr; } //------------------------------------------------------------------------------ // instance //------------------------------------------------------------------------------ cta::log::Logger &cta::log::instance() { - if(NULL == s_logger) { + if(nullptr == s_logger) { throw cta::exception::Exception("Failed to get CASTOR logger" ": Logger does not exist"); } diff --git a/common/processCap/ProcessCap.cpp b/common/processCap/ProcessCap.cpp index 421a9af6682f2b523200066d79aa287d582c6a7a..d425f81fa270528d5310cc527a2439a784619fbc 100644 --- a/common/processCap/ProcessCap.cpp +++ b/common/processCap/ProcessCap.cpp @@ -48,10 +48,10 @@ std::string cta::server::ProcessCap::getProcText() { //------------------------------------------------------------------------------ cap_t cta::server::ProcessCap::getProc() { cap_t cap = cap_get_proc(); - if(NULL == cap) { + if(nullptr == cap) { cta::exception::Exception ex; ex.getMessage() << - "Failed to get the capabilities of the process: " + "Failed to get the capabilities of the process: " << cta::utils::errnoToString(errno); throw ex; } @@ -64,11 +64,11 @@ cap_t cta::server::ProcessCap::getProc() { std::string cta::server::ProcessCap::toText( const cap_t cap) { // Create a C++ string with the result of calling cap_to_text() - char *const text = cap_to_text(cap, NULL); - if(NULL == text) { + char *const text = cap_to_text(cap, nullptr); + if(nullptr == text) { cta::exception::Exception ex; ex.getMessage() << - "Failed to create string representation of capability state: " + "Failed to create string representation of capability state: " << cta::utils::errnoToString(errno); throw ex; } @@ -78,7 +78,7 @@ std::string cta::server::ProcessCap::toText( if(cap_free(text)) { cta::exception::Exception ex; ex.getMessage() << - "Failed to free string representation of capability state: " + "Failed to free string representation of capability state: " << cta::utils::errnoToString(errno); throw ex; } @@ -107,7 +107,7 @@ void cta::server::ProcessCap::setProcText(const std::string &text) { //------------------------------------------------------------------------------ cap_t cta::server::ProcessCap::fromText(const std::string &text) { const cap_t cap = cap_from_text(text.c_str()); - if(NULL == cap) { + if(nullptr == cap) { cta::exception::Exception ex; ex.getMessage() << "Failed to create capability state from string representation" @@ -125,7 +125,7 @@ void cta::server::ProcessCap::setProc(const cap_t cap) { if(cap_set_proc(cap)) { cta::exception::Exception ex; ex.getMessage() << - "Failed to set the capabilities of the process: " + "Failed to set the capabilities of the process: " << cta::utils::errnoToString(errno); throw ex; } diff --git a/common/processCap/SmartCap.cpp b/common/processCap/SmartCap.cpp index 954d14e27b957e24160e034feb33eb71764ef191..3775be4c4c7c60e7dde2cf1696e5d15f0fbbe8bf 100644 --- a/common/processCap/SmartCap.cpp +++ b/common/processCap/SmartCap.cpp @@ -22,7 +22,7 @@ // constructor //------------------------------------------------------------------------------ cta::server::SmartCap::SmartCap() throw(): - m_cap(NULL) { + m_cap(nullptr) { } //------------------------------------------------------------------------------ @@ -41,7 +41,7 @@ void cta::server::SmartCap::reset(cap_t cap) throw() { // If this smart pointer still owns a capability state then free it using // cap_free() - if(NULL != m_cap) { + if(nullptr != m_cap) { cap_free(m_cap); } @@ -77,15 +77,15 @@ cap_t cta::server::SmartCap::get() const throw() { //------------------------------------------------------------------------------ cap_t cta::server::SmartCap::release() { // If this smart pointer does not own a capbility state - if(NULL == m_cap) { + if(nullptr == m_cap) { cta::exception::Exception ex; ex.getMessage() << "Smart pointer does not own a capbility state"; throw(ex); } - // Assigning NULL to m_cap indicates this smart pointer does not own a + // Assigning nullptr to m_cap indicates this smart pointer does not own a // capability state cap_t tmpCap = m_cap; - m_cap = NULL; + m_cap = nullptr; return tmpCap; } diff --git a/common/processCap/SmartCap.hpp b/common/processCap/SmartCap.hpp index 9bd1c3b2debfb77448d56abd2ec297d6dbf3449b..0c4edc700691ba7ad949fcfb0c73fef87576039a 100644 --- a/common/processCap/SmartCap.hpp +++ b/common/processCap/SmartCap.hpp @@ -51,11 +51,11 @@ public: * then it will be freed using cap_free(). * * @param cap The capability state to be owned. If a capabibility state is - * not specified then the default value of NULL will be used. In this default + * not specified then the default value of nullptr will be used. In this default * case the smart pointer will not own a capbility state after the reset() * method returns. */ - void reset(cap_t cap = NULL) throw(); + void reset(cap_t cap = nullptr) throw(); /** * SmartCap assignment operator. @@ -72,15 +72,15 @@ public: /** * Destructor. * - * Resets this smart pointer with the default value of NULL. + * Resets this smart pointer with the default value of nullptr. */ ~SmartCap() throw(); /** - * Returns the owned capbility state or NULL if this smart pointer does not + * Returns the owned capbility state or nullptr if this smart pointer does not * own one. * - * @return The owned capbility state or NULL if this smart pointer does not + * @return The owned capbility state or nullptr if this smart pointer does not * own one. */ cap_t get() const throw(); @@ -95,8 +95,8 @@ public: private: /** - * The owned capbility state or NULL if this smart pointer does not own one. - */ + * The owned capbility state or nullptr if this smart pointer does not own one. + */ cap_t m_cap; /** @@ -110,4 +110,3 @@ private: }; // class SmartCap }} // namespace cta::server - diff --git a/common/processCap/SmartCapTest.cpp b/common/processCap/SmartCapTest.cpp index e4a55c19eeec810278265f330e48804c87f4012b..a9a7d331d102d5eabaf58c82c078d354524b9d45 100644 --- a/common/processCap/SmartCapTest.cpp +++ b/common/processCap/SmartCapTest.cpp @@ -34,12 +34,12 @@ protected: TEST_F(cta_server_SmartCapTest, default_constructor) { cta::server::SmartCap smartPtr; - ASSERT_EQ((cap_t)NULL, smartPtr.get()); + ASSERT_EQ(nullptr, smartPtr.get()); } TEST_F(cta_server_SmartCapTest, constructor) { cap_t cap = cap_get_proc(); - ASSERT_NE((cap_t)NULL, cap); + ASSERT_NE(nullptr, cap); cta::server::SmartCap smartPtr(cap); ASSERT_EQ(cap, smartPtr.get()); @@ -47,10 +47,10 @@ TEST_F(cta_server_SmartCapTest, constructor) { TEST_F(cta_server_SmartCapTest, reset) { cta::server::SmartCap smartPtr; - ASSERT_EQ((cap_t)NULL, smartPtr.get()); + ASSERT_EQ(nullptr, smartPtr.get()); cap_t cap = cap_get_proc(); - ASSERT_NE((cap_t)NULL, cap); + ASSERT_NE(nullptr, cap); smartPtr.reset(cap); ASSERT_EQ(cap, smartPtr.get()); @@ -58,19 +58,19 @@ TEST_F(cta_server_SmartCapTest, reset) { TEST_F(cta_server_SmartCapTest, assignment) { cap_t cap = cap_get_proc(); - ASSERT_NE((cap_t)NULL, cap); + ASSERT_NE(nullptr, cap); cta::server::SmartCap smartPtr1; cta::server::SmartCap smartPtr2; - ASSERT_EQ((cap_t)NULL, smartPtr1.get()); - ASSERT_EQ((cap_t)NULL, smartPtr2.get()); + ASSERT_EQ(nullptr, smartPtr1.get()); + ASSERT_EQ(nullptr, smartPtr2.get()); smartPtr1.reset(cap); ASSERT_EQ(cap, smartPtr1.get()); smartPtr2 = smartPtr1; - ASSERT_EQ((cap_t)NULL, smartPtr1.get()); + ASSERT_EQ(nullptr, smartPtr1.get()); ASSERT_EQ(cap, smartPtr2.get()); } diff --git a/common/threading/BlockingQueue.hpp b/common/threading/BlockingQueue.hpp index 94c30e2b336cfec868cd09971a51fa3b33ed8c42..ef50ced4981127f294dee3f0628580e16f812174 100644 --- a/common/threading/BlockingQueue.hpp +++ b/common/threading/BlockingQueue.hpp @@ -26,10 +26,10 @@ namespace cta { namespace threading { - + /*** * This simple class provides a thread-safe blocking queue - * + * */ template<class C> class BlockingQueue { @@ -40,10 +40,10 @@ public: typedef typename std::queue<C>::reference reference; typedef typename std::queue<C>::const_reference const_reference; typedef struct valueRemainingPair {C value; size_t remaining;} valueRemainingPair; - + BlockingQueue(){} ~BlockingQueue() {} - + /** * Copy the concent of e and push into the queue * @param e @@ -67,7 +67,7 @@ public: } m_sem.release(); } - + /** * Return the next value of the queue and remove it */ @@ -76,11 +76,11 @@ public: return popCriticalSection(); } /** - * Atomically pop the element of the top of the pile AND return it with the - * number of remaining elements in the queue - * @return a struct holding the popped element (into ret.value) and the number of elements + * Atomically pop the element of the top of the pile AND return it with the + * number of remaining elements in the queue + * @return a struct holding the popped element (into ret.value) and the number of elements * remaining (into ret.remaining) - * + * */ valueRemainingPair popGetSize () { m_sem.acquire(); @@ -88,36 +88,36 @@ public: ret.value = popCriticalSection(&ret.remaining); return ret; } - + /** * return the number of elements currently in the queue */ - size_t size() const { + size_t size() const { MutexLocker ml(m_mutex); return m_queue.size(); } - -private: - /** - * holds data of the queue + +private: + /** + * holds data of the queue */ std::queue<C> m_queue; - + /** - * Used for blocking a consumer thread as long as the queue is empty + * Used for blocking a consumer thread as long as the queue is empty */ Semaphore m_sem; - + /** * used for locking-operation thus providing thread-safety */ mutable Mutex m_mutex; /** - * Thread and exception safe pop. Optionally atomically extracts the size - * of the queue after pop + * Thread and exception safe pop. Optionally atomically extracts the size + * of the queue after pop */ - C popCriticalSection(size_t * sz = NULL) { + C popCriticalSection(size_t * sz = nullptr) { MutexLocker ml(m_mutex); C ret = std::move(m_queue.front()); m_queue.pop(); @@ -125,8 +125,8 @@ private: *sz = m_queue.size(); return ret; } - + }; } // namespace threading -} // namespace cta \ No newline at end of file +} // namespace cta diff --git a/common/threading/DaemonTest.cpp b/common/threading/DaemonTest.cpp index db49eae63110df3dfc366f1c736028f19579a89b..2152b9a502eefe13b705f6487a1caa4817256279 100644 --- a/common/threading/DaemonTest.cpp +++ b/common/threading/DaemonTest.cpp @@ -37,12 +37,12 @@ protected: m_hostName("dummy"), m_programName("testdaemon"), m_argc(0), - m_argv(NULL) { + m_argv(nullptr) { } virtual void SetUp() { m_argc = 0; - m_argv = NULL; + m_argv = nullptr; } virtual void TearDown() { @@ -57,7 +57,7 @@ protected: TEST_F(cta_threading_DaemonTest, getForegroundBeforeParseCommandLine) { cta::log::DummyLogger log(m_hostName, m_programName); cta::server::Daemon daemon(log); - + ASSERT_THROW(daemon.getForeground(), cta::server::Daemon::CommandLineNotParsed); } diff --git a/common/threading/Semaphores.cpp b/common/threading/Semaphores.cpp index 780c00568f71fbdfe1ea165a2b6640db3ce7cf32..b4aff7f9d4481291c05458c068c8b3feee414223 100644 --- a/common/threading/Semaphores.cpp +++ b/common/threading/Semaphores.cpp @@ -23,9 +23,9 @@ #include <errno.h> #include <sys/time.h> -namespace cta { +namespace cta { namespace threading { - + //------------------------------------------------------------------------------ //PosixSemaphore constructor //------------------------------------------------------------------------------ @@ -64,7 +64,7 @@ void PosixSemaphore::acquireWithTimeout(uint64_t timeout_us) { int ret; struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); struct timespec ts; // Add microseconds ts.tv_nsec = (tv.tv_usec + (timeout_us % 1000000)) * 1000; @@ -110,10 +110,10 @@ void PosixSemaphore::release(int n) //------------------------------------------------------------------------------ CondVarSemaphore::CondVarSemaphore(int initial):m_value(initial) { cta::exception::Errnum::throwOnReturnedErrno( - pthread_cond_init(&m_cond, NULL), + pthread_cond_init(&m_cond, nullptr), "Error from pthread_cond_init in cta::threading::CondVarSemaphore::CondVarSemaphore()"); cta::exception::Errnum::throwOnReturnedErrno( - pthread_mutex_init(&m_mutex, NULL), + pthread_mutex_init(&m_mutex, nullptr), "Error from pthread_mutex_init in cta::threading::CondVarSemaphore::CondVarSemaphore()"); } @@ -186,4 +186,4 @@ void CondVarSemaphore::release(int n) } } // namespace threading -} // namespace cta \ No newline at end of file +} // namespace cta diff --git a/common/threading/SubProcess.cpp b/common/threading/SubProcess.cpp index 9b8216ad210112f7d0dd70d71d0b6a929b3b4a62..2404e40635af5be837a084a5a04d449527415adb 100644 --- a/common/threading/SubProcess.cpp +++ b/common/threading/SubProcess.cpp @@ -72,11 +72,11 @@ SubProcess::SubProcess(const std::string & executable, const std::list<std::stri int stdoutPipe[2]; int stderrPipe[2]; int stdinPipe[2]; - cta::exception::Errnum::throwOnNonZero(::pipe2(stdoutPipe, O_NONBLOCK), + cta::exception::Errnum::throwOnNonZero(::pipe2(stdoutPipe, O_NONBLOCK), "In Subprocess::Subprocess failed to create the stdout pipe"); - cta::exception::Errnum::throwOnNonZero(::pipe2(stderrPipe, O_NONBLOCK), + cta::exception::Errnum::throwOnNonZero(::pipe2(stderrPipe, O_NONBLOCK), "In Subprocess::Subprocess failed to create the stderr pipe"); - cta::exception::Errnum::throwOnNonZero(::pipe2(stdinPipe,O_NONBLOCK), + cta::exception::Errnum::throwOnNonZero(::pipe2(stdinPipe,O_NONBLOCK), "In Subprocess::Subprocess failed to create the stdin pipe"); // Prepare the actions to be taken on file descriptors ScopedPosixSpawnFileActions fileActions; @@ -103,7 +103,7 @@ SubProcess::SubProcess(const std::string & executable, const std::list<std::stri "In Subprocess::Subprocess(): failed to posix_spawn_file_actions_addclose() (5)"); cta::exception::Errnum::throwOnReturnedErrno(posix_spawn_file_actions_addclose(fileActions, stdinPipe[readSide]), "In Subprocess::Subprocess(): failed to posix_spawn_file_actions_addclose() (6)"); - + // And finally spawn the subprocess // Prepare the spawn attributes (we need vfork) ScopedPosixSpawnAttr attr; @@ -119,7 +119,7 @@ SubProcess::SubProcess(const std::string & executable, const std::list<std::stri cargvStrings.emplace_back(std::move(upStr)); index++; } - cargv[argv.size()] = NULL; + cargv[argv.size()] = nullptr; int spawnRc=::posix_spawnp(&m_child, executable.c_str(), fileActions, attr, cargv.get(), ::environ); cta::exception::Errnum::throwOnReturnedErrno(spawnRc, "In Subprocess::Subprocess failed to posix_spawn()"); } diff --git a/common/threading/System.cpp b/common/threading/System.cpp index c530d801459331b5b0aa47d75ca0efb19cb7724d..9ed2a1f3f4cc062e26336818644d70ba608063cf 100644 --- a/common/threading/System.cpp +++ b/common/threading/System.cpp @@ -30,7 +30,7 @@ //------------------------------------------------------------------------------ // getHostName //------------------------------------------------------------------------------ -std::string cta::System::getHostName() +std::string cta::System::getHostName() { // All this to get the hostname, thanks to C ! int len = 64; @@ -122,19 +122,19 @@ void cta::System::setUserAndGroup(const std::string &userName, const std::string const gid_t egid = getegid(); // Get information on generic stage account from password file - if ((pwd = getpwnam(userName.c_str())) == NULL) { + if ((pwd = getpwnam(userName.c_str())) == nullptr) { cta::exception::Exception e; e.getMessage() << "Failed to " << task << ": User name not found in password file"; throw e; } // verify existence of its primary group id - if (getgrgid(pwd->pw_gid) == NULL) { + if (getgrgid(pwd->pw_gid) == nullptr) { cta::exception::Exception e; e.getMessage() << "Failed to " << task << ": User does not have a primary group"; throw e; } // Get information about group name from group file - if ((grp = getgrnam(groupName.c_str())) == NULL) { + if ((grp = getgrnam(groupName.c_str())) == nullptr) { cta::exception::Exception e; e.getMessage() << "Failed to " << task << ": Group name not found in group file"; throw e; diff --git a/common/threading/Thread.cpp b/common/threading/Thread.cpp index dd449464abbc588a3cb9990c74b02f867f4cbafc..2f547fad12d21f0d587c5cb54a02af0737e37652 100644 --- a/common/threading/Thread.cpp +++ b/common/threading/Thread.cpp @@ -22,9 +22,9 @@ #include <cxxabi.h> #include <iostream> -namespace cta { +namespace cta { namespace threading { - + /* Implmentations of the threading primitives */ //------------------------------------------------------------------------------ //start @@ -80,22 +80,22 @@ void Thread::kill() //------------------------------------------------------------------------------ void * Thread::pthread_runner (void * arg) { - /* static_casting a pointer to and from void* preserves the address. + /* static_casting a pointer to and from void* preserves the address. * See https://stackoverflow.com/questions/573294/when-to-use-reinterpret-cast - */ + */ Thread * _this = static_cast<Thread *>(arg); // Set the thread cancellation type to immediate, for use in the tapeResourceManager tests - cta::exception::Errnum::throwOnReturnedErrno(::pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL), + cta::exception::Errnum::throwOnReturnedErrno(::pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr), "Error from pthread_setcancelstate in cta::threading::Thread::pthread_runner"); - cta::exception::Errnum::throwOnReturnedErrno(::pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL), + cta::exception::Errnum::throwOnReturnedErrno(::pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr), "Error from pthread_setcanceltype in cta::threading::Thread::pthread_runner"); try { _this->run(); } catch (std::exception & e) { _this->m_hadException = true; int status = -1; - char * demangled = abi::__cxa_demangle(typeid(e).name(), NULL, NULL, &status); + char * demangled = abi::__cxa_demangle(typeid(e).name(), nullptr, nullptr, &status); if (!status) { _this->m_type += demangled; } else { @@ -109,8 +109,8 @@ void * Thread::pthread_runner (void * arg) { _this->m_what = "uncaught non-standard exception"; throw; } - return NULL; + return nullptr; } } // namespace threading -} // namespace cta \ No newline at end of file +} // namespace cta diff --git a/common/threading/ThreadingMPTests.cpp b/common/threading/ThreadingMPTests.cpp index 32ed199f0046dc639013d3cf0ba67825281a98bb..e902bbde0d37ebc79600dbb8e32dfd1384127467 100644 --- a/common/threading/ThreadingMPTests.cpp +++ b/common/threading/ThreadingMPTests.cpp @@ -38,7 +38,7 @@ namespace threadedUnitTests { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 100*1000*1000; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); return 123; } }; @@ -62,7 +62,7 @@ namespace threadedUnitTests { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 10*1000*1000; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); } return 321; } @@ -80,7 +80,7 @@ namespace threadedUnitTests { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 100*1000*1000; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); ASSERT_FALSE(cp.running()); EXPECT_THROW(cp.exitCode(), cta::threading::ChildProcess::ProcessWasKilled); } diff --git a/common/utils/UtilsTest.cpp b/common/utils/UtilsTest.cpp index ad42ff7aaad694a1ed0ae9e8ffd9bf52d02877f6..6cbeedb37538448187a058a9f294547ccf8ba7b5 100644 --- a/common/utils/UtilsTest.cpp +++ b/common/utils/UtilsTest.cpp @@ -100,7 +100,7 @@ TEST_F(cta_UtilsTest, TEST_F(cta_UtilsTest, getEnclosingPath_empty_string) { using namespace cta; - + const std::string dirPath = ""; ASSERT_THROW(utils::getEnclosingPath(dirPath), std::exception); @@ -108,7 +108,7 @@ TEST_F(cta_UtilsTest, getEnclosingPath_empty_string) { TEST_F(cta_UtilsTest, getEnclosingPath_root) { using namespace cta; - + const std::string dirPath = "/"; std::string enclosingPath; @@ -120,7 +120,7 @@ TEST_F(cta_UtilsTest, getEnclosingPath_grandparent) { using namespace cta; const std::string dirPath = "/grandparent"; - + std::string enclosingPath; ASSERT_NO_THROW(enclosingPath = utils::getEnclosingPath(dirPath)); ASSERT_EQ(std::string("/"), enclosingPath); @@ -254,7 +254,7 @@ TEST_F(cta_UtilsTest, endsWith_slash_non_empty_string_without_terminating_slash) using namespace cta; const std::string str = "abcde"; ASSERT_FALSE(utils::endsWith(str, '/')); -} +} TEST_F(cta_UtilsTest, endsWith_slash_non_empty_string_with_terminating_slash) { using namespace cta; @@ -266,7 +266,7 @@ TEST_F(cta_UtilsTest, endsWith_slash_just_a_slash) { using namespace cta; const std::string str = "/"; ASSERT_TRUE(utils::endsWith(str, '/')); -} +} TEST_F(cta_UtilsTest, errnoToString_EACCESS) { using namespace cta; @@ -638,7 +638,7 @@ TEST_F(cta_UtilsTest, adler32_empty_buf) { using namespace cta; // The adler32 of an empty buffer is 1 - ASSERT_EQ((uint32_t)1, utils::getAdler32(NULL, 0)); + ASSERT_EQ((uint32_t)1, utils::getAdler32(nullptr, 0)); } TEST_F(cta_UtilsTest, adler32_buf_of_character_1) { @@ -832,7 +832,7 @@ TEST_F(cta_UtilsTest, testCopyStringNullDst) { using namespace cta; char dummy[6] = "Dummy"; - ASSERT_THROW(utils::copyString(NULL, 0, dummy), + ASSERT_THROW(utils::copyString(nullptr, 0, dummy), cta::exception::Exception); } @@ -847,7 +847,7 @@ TEST_F(cta_UtilsTest, testCopyString) { TEST_F(cta_UtilsTest, ellipses) { using namespace cta::utils; - + ASSERT_EQ("1234567890", postEllipsis("1234567890", 12)); ASSERT_EQ("1234567[...]", postEllipsis("1234567890ABCDEF", 12)); ASSERT_EQ("1234567890", midEllipsis("1234567890", 12)); @@ -857,7 +857,7 @@ TEST_F(cta_UtilsTest, ellipses) { } TEST_F(cta_UtilsTest, DISABLED_currentTime) { - /* This test is disabled as it prints our similar, yet slightly different dates, + /* This test is disabled as it prints our similar, yet slightly different dates, * so it would be complex to automate. * Just run with: "cta-unitTests --gtest_filter=*currentTime --gtest_also_run_disabled_tests" */ using namespace cta::utils; @@ -883,21 +883,21 @@ TEST_F(cta_UtilsTest, appendParameterXRootFileURL){ cta::utils::appendParameterXRootFileURL(fileURL,"oss.asize","145"); //nothing should have changed ASSERT_EQ(fileURLTest,fileURL); - + fileURLTest = "root://ctaeos.cta.svc.cluster.local//eos/ctaeos/preprod/79fe26de-6b8b-437c-b507-06dbfe8d0a79/0/test00000171"; fileURL = fileURLTest; cta::utils::appendParameterXRootFileURL(fileURL,"oss.asize","15360"); ASSERT_EQ(fileURLTest+"?oss.asize=15360",fileURL); - + fileURLTest = "file://path_to_folder/path_to_file"; fileURL = fileURLTest; cta::utils::appendParameterXRootFileURL(fileURL,"oss.asize","15360"); ASSERT_EQ(fileURLTest,fileURL); - + fileURLTest = "root://ctaeos.cta.svc.cluster.local//eos/ctaeos/preprod/79fe26de-6b8b-437c-b507-06dbfe8d0a79/0/test00000171?eos.lfn=fxid:b2&eos.ruid=0&eos.rgid=0&eos.injection=1&eos.workflow=retrieve_written&eos.space=default"; fileURL = fileURLTest; cta::utils::appendParameterXRootFileURL(fileURL,"oss.asize","15360"); - ASSERT_EQ(fileURLTest+"&oss.asize=15360",fileURL); + ASSERT_EQ(fileURLTest+"&oss.asize=15360",fileURL); } } // namespace unitTests diff --git a/common/utils/utils.cpp b/common/utils/utils.cpp index c64636b9224c7fdebc1bc96a16d10d47237bc9e0..580797b5b2c1dc2d7d9a3617073671b9c0ca3911 100644 --- a/common/utils/utils.cpp +++ b/common/utils/utils.cpp @@ -429,7 +429,7 @@ void setXattr(const std::string &path, const std::string &name, //------------------------------------------------------------------------------ std::string getXattr(const std::string &path, const std::string &name) { - const auto sizeOfValue = getxattr(path.c_str(), name.c_str(), NULL, 0); + const auto sizeOfValue = getxattr(path.c_str(), name.c_str(), nullptr, 0); if(0 > sizeOfValue) { const int savedErrno = errno; std::stringstream msg; @@ -502,7 +502,7 @@ uint8_t toUint8(const std::string &str) { } errno = 0; - const long int value = strtol(str.c_str(), (char **) NULL, 10); + const long int value = strtol(str.c_str(), (char **) nullptr, 10); const int savedErrno = errno; if(savedErrno) { std::ostringstream msg; @@ -538,7 +538,7 @@ uint16_t toUint16(const std::string &str) { } errno = 0; - const long int value = strtol(str.c_str(), (char **) NULL, 10); + const long int value = strtol(str.c_str(), (char **) nullptr, 10); const int savedErrno = errno; if(savedErrno) { std::ostringstream msg; @@ -574,7 +574,7 @@ uint32_t toUint32(const std::string &str) { } errno = 0; - const long int value = strtol(str.c_str(), (char **) NULL, 10); + const long int value = strtol(str.c_str(), (char **) nullptr, 10); const int savedErrno = errno; if(savedErrno) { std::ostringstream msg; @@ -610,7 +610,7 @@ uid_t toUid(const std::string &str) { } errno = 0; - const long int value = strtol(str.c_str(), (char **) NULL, 10); + const long int value = strtol(str.c_str(), (char **) nullptr, 10); const int savedErrno = errno; if(savedErrno) { std::ostringstream msg; @@ -646,7 +646,7 @@ gid_t toGid(const std::string &str) { } errno = 0; - const long int value = strtol(str.c_str(), (char **) NULL, 10); + const long int value = strtol(str.c_str(), (char **) nullptr, 10); const int savedErrno = errno; if(savedErrno) { std::ostringstream msg; @@ -880,11 +880,11 @@ std::string hexDump(const void * mem, unsigned int n ){ // copyString //----------------------------------------------------------------------------- void copyString(char *const dst, const size_t dstSize, const std::string &src) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << __FUNCTION__ - << ": Pointer to destination string is NULL"; + << ": Pointer to destination string is nullptr"; throw ex; } @@ -992,7 +992,7 @@ std::string removePrefix(const std::string& input, char prefixChar){ std::string getEnv(const std::string& variableName){ const char * envVarC = std::getenv(variableName.c_str()); - if(envVarC == NULL){ + if(envVarC == nullptr){ return ""; } return std::string(envVarC); diff --git a/disk/DiskFile.cpp b/disk/DiskFile.cpp index addccf0c484c8554877bd881505be71976ac7bc1..69fef3a40fdfa95e544305d4f963cf354c51a0bb 100644 --- a/disk/DiskFile.cpp +++ b/disk/DiskFile.cpp @@ -55,7 +55,7 @@ const CryptoPP::RSA::PrivateKey & DiskFileFactory::xrootPrivateKey() { // This is an experimental workaround. static cta::threading::Mutex mutex; cta::threading::MutexLocker ml(mutex); - // The loading of a PEM-style key is described in + // The loading of a PEM-style key is described in // http://www.cryptopp.com/wiki/Keys_and_Formats#PEM_Encoded_Keys std::string key; std::ifstream keyFile(m_xrootPrivateKeyFile.c_str()); @@ -71,39 +71,39 @@ const CryptoPP::RSA::PrivateKey & DiskFileFactory::xrootPrivateKey() { } const std::string HEADER = "-----BEGIN RSA PRIVATE KEY-----"; const std::string FOOTER = "-----END RSA PRIVATE KEY-----"; - + size_t pos1, pos2; pos1 = key.find(HEADER); if(pos1 == std::string::npos) throw cta::exception::Exception( "In DiskFileFactory::xrootCryptoPPPrivateKey, PEM header not found"); - + pos2 = key.find(FOOTER, pos1+1); if(pos2 == std::string::npos) throw cta::exception::Exception( "In DiskFileFactory::xrootCryptoPPPrivateKey, PEM footer not found"); - + // Start position and length pos1 = pos1 + HEADER.length(); pos2 = pos2 - pos1; std::string keystr = key.substr(pos1, pos2); - - // Base64 decode, place in a ByteQueue + + // Base64 decode, place in a ByteQueue CryptoPP::ByteQueue queue; CryptoPP::Base64Decoder decoder; - + decoder.Attach(new CryptoPP::Redirector(queue)); decoder.Put((const byte*)keystr.data(), keystr.length()); decoder.MessageEnd(); m_xrootPrivateKey.BERDecodePrivateKey(queue, false /*paramsPresent*/, queue.MaxRetrievable()); - + // BERDecodePrivateKey is a void function. Here's the only check // we have regarding the DER bytes consumed. if(!queue.IsEmpty()) throw cta::exception::Exception( "In DiskFileFactory::xrootCryptoPPPrivateKey, garbage at end of key"); - + CryptoPP::AutoSeededRandomPool prng; bool valid = m_xrootPrivateKey.Validate(prng, 3); if(!valid) @@ -207,7 +207,7 @@ WriteFile * DiskFileFactory::createWriteFile(const std::string& path) { //============================================================================== // LOCAL READ FILE -//============================================================================== +//============================================================================== LocalReadFile::LocalReadFile(const std::string &path) { m_fd = ::open64((char *)path.c_str(), O_RDONLY); m_URL = "file://"; @@ -222,12 +222,12 @@ size_t LocalReadFile::read(void *data, const size_t size) const { } size_t LocalReadFile::size() const { - //struct is mandatory here, because there is a function stat64 - struct stat64 statbuf; + //struct is mandatory here, because there is a function stat64 + struct stat64 statbuf; int ret = ::fstat64(m_fd,&statbuf); cta::exception::Errnum::throwOnMinusOne(ret, std::string("In diskFile::LocalReadFile::LocalReadFile failed stat64() on ")+m_URL); - + return statbuf.st_size; } @@ -237,7 +237,7 @@ LocalReadFile::~LocalReadFile() throw() { //============================================================================== // LOCAL WRITE FILE -//============================================================================== +//============================================================================== LocalWriteFile::LocalWriteFile(const std::string &path): m_closeTried(false){ // For local files, we truncate the file like for RFIO m_fd = ::open64((char *)path.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666); @@ -245,7 +245,7 @@ LocalWriteFile::LocalWriteFile(const std::string &path): m_closeTried(false){ m_URL += path; cta::exception::Errnum::throwOnMinusOne(m_fd, std::string("In LocalWriteFile::LocalWriteFile() failed to open64() on ") - +m_URL); + +m_URL); } @@ -262,7 +262,7 @@ void LocalWriteFile::close() { if (m_closeTried) return; m_closeTried=true; cta::exception::Errnum::throwOnMinusOne(::close(m_fd), - std::string("In LocalWriteFile::close failed close() on ")+m_URL); + std::string("In LocalWriteFile::close failed close() on ")+m_URL); } LocalWriteFile::~LocalWriteFile() throw() { @@ -276,7 +276,7 @@ LocalWriteFile::~LocalWriteFile() throw() { //============================================================================== cta::threading::Mutex CryptoPPSigner::s_mutex; -std::string CryptoPPSigner::sign(const std::string msg, +std::string CryptoPPSigner::sign(const std::string msg, const CryptoPP::RSA::PrivateKey& privateKey) { // Global lock as Crypto++ seems not to be thread safe (helgrind complains) cta::threading::MutexLocker ml(s_mutex); @@ -288,7 +288,7 @@ std::string CryptoPPSigner::sign(const std::string msg, CryptoPP::AutoSeededRandomPool rng; // Construct a pipe: msg -> sign -> Base64 encode -> result goes into ret. const bool noNewLineInBase64Output = false; - CryptoPP::StringSource ss1(msg, true, + CryptoPP::StringSource ss1(msg, true, new CryptoPP::SignerFilter(rng, signer, new CryptoPP::Base64Encoder( new CryptoPP::StringSink(ret), noNewLineInBase64Output))); @@ -298,7 +298,7 @@ std::string CryptoPPSigner::sign(const std::string msg, //============================================================================== // XROOT READ FILE -//============================================================================== +//============================================================================== XrootC2FSReadFile::XrootC2FSReadFile(const std::string &url, const CryptoPP::RSA::PrivateKey & xrootPrivateKey, uint16_t timeout, const std::string & pool): XrootBaseReadFile(timeout) { @@ -319,18 +319,18 @@ XrootC2FSReadFile::XrootC2FSReadFile(const std::string &url, // after the inital [x]root:// const std::string scheme = "root://"; size_t schemePos = url.find(scheme); - if (std::string::npos == schemePos) + if (std::string::npos == schemePos) throw cta::exception::Exception( std::string("In XrootC2FSReadFile::XrootC2FSReadFile could not find the scheme[x]root:// in URL "+ url)); size_t pathPos = url.find("/", schemePos + scheme.size()); - if (std::string::npos == pathPos) + if (std::string::npos == pathPos) throw cta::exception::Exception( std::string("In XrootC2FSReadFile::XrootC2FSReadFile could not path in URL "+ url)); // Build signature block std::string path = url.substr(pathPos + 1); - time_t expTime = time(NULL)+3600; + time_t expTime = time(nullptr)+3600; uuid_t uuid; char suuid[100]; uuid_generate(uuid); @@ -349,7 +349,7 @@ XrootC2FSReadFile::XrootC2FSReadFile(const std::string &url, opaqueBloc << "&castor.txtype=tape"; opaqueBloc << "&castor.signature=" << signature; m_signedURL = m_URL + opaqueBloc.str(); - + // ... and finally open the file XrootClEx::throwOnError(m_xrootFile.Open(m_signedURL, OpenFlags::Read, XrdCl::Access::None, m_timeout), std::string("In XrootC2FSReadFile::XrootC2FSReadFile failed XrdCl::File::Open() on ") @@ -378,7 +378,7 @@ size_t XrootBaseReadFile::read(void *data, const size_t size) const { size_t XrootBaseReadFile::size() const { const bool forceStat=false; - XrdCl::StatInfo *statInfo(NULL); + XrdCl::StatInfo *statInfo(nullptr); size_t ret; XrootClEx::throwOnError(m_xrootFile.Stat(forceStat, statInfo, m_timeout), std::string("In XrootReadFile::size failed XrdCl::File::Stat() on ")+m_URL); @@ -399,7 +399,7 @@ XrootBaseReadFile::~XrootBaseReadFile() throw() { //============================================================================== // XROOT WRITE FILE -//============================================================================== +//============================================================================== XrootC2FSWriteFile::XrootC2FSWriteFile(const std::string &url, const CryptoPP::RSA::PrivateKey & xrootPrivateKey, uint16_t timeout, const std::string & pool): @@ -419,18 +419,18 @@ XrootC2FSWriteFile::XrootC2FSWriteFile(const std::string &url, // after the inital [x]root:// const std::string scheme = "root://"; size_t schemePos = url.find(scheme); - if (std::string::npos == schemePos) + if (std::string::npos == schemePos) throw cta::exception::Exception( std::string("In XrootC2FSWriteFile::XrootC2FSWriteFile could not find the scheme[x]root:// in URL "+ url)); size_t pathPos = url.find("/", schemePos + scheme.size()); - if (std::string::npos == pathPos) + if (std::string::npos == pathPos) throw cta::exception::Exception( std::string("In XrootC2FSWriteFile::XrootC2FSWriteFile could not path in URL "+ url)); // Build signature block std::string path = url.substr(pathPos + 1); - time_t expTime = time(NULL)+3600; + time_t expTime = time(nullptr)+3600; uuid_t uuid; char suuid[100]; uuid_generate(uuid); @@ -449,7 +449,7 @@ XrootC2FSWriteFile::XrootC2FSWriteFile(const std::string &url, opaqueBloc << "&castor.txtype=tape"; opaqueBloc << "&castor.signature=" << signature; m_signedURL = m_URL + opaqueBloc.str(); - + // ... and finally open the file for write (deleting any existing one in case) XrootClEx::throwOnError(m_xrootFile.Open(m_signedURL, OpenFlags::Delete | OpenFlags::Write, XrdCl::Access::None, m_timeout), @@ -533,7 +533,7 @@ RadosStriperReadFile::~RadosStriperReadFile() throw() {} //============================================================================== // RADOS STRIPER WRITE FILE -//============================================================================== +//============================================================================== RadosStriperWriteFile::RadosStriperWriteFile(const std::string &fullURL, libradosstriper::RadosStriper * striper, const std::string &osd): m_striper(striper), @@ -645,7 +645,7 @@ void XRootdDiskFileRemover::removeAsync(AsyncXRootdDiskFileRemover::XRootdFileRe //============================================================================== // AsyncXrootdDiskFileRemover -//============================================================================== +//============================================================================== AsyncXRootdDiskFileRemover::AsyncXRootdDiskFileRemover(const std::string &path){ m_diskFileRemover.reset(new XRootdDiskFileRemover(path)); } @@ -669,9 +669,9 @@ void AsyncXRootdDiskFileRemover::XRootdFileRemoverResponseHandler::HandleRespons //============================================================================== // AsyncLocalDiskFileRemover -//============================================================================== +//============================================================================== AsyncLocalDiskFileRemover::AsyncLocalDiskFileRemover(const std::string& path){ - m_diskFileRemover.reset(new LocalDiskFileRemover(path)); + m_diskFileRemover.reset(new LocalDiskFileRemover(path)); } void AsyncLocalDiskFileRemover::asyncDelete(){ @@ -684,7 +684,7 @@ void AsyncLocalDiskFileRemover::wait(){ //============================================================================== // DIRECTORY FACTORY -//============================================================================== +//============================================================================== DirectoryFactory::DirectoryFactory(): m_URLLocalDirectory("^file://(.*)$"), m_URLXrootDirectory("^(root://.*)$"){} @@ -708,7 +708,7 @@ Directory * DirectoryFactory::createDirectory(const std::string& path){ //============================================================================== // LOCAL DIRECTORY -//============================================================================== +//============================================================================== LocalDirectory::LocalDirectory(const std::string& path){ m_URL = path; } @@ -734,7 +734,7 @@ std::set<std::string> LocalDirectory::getFilesName(){ struct dirent *file; dir = opendir(m_URL.c_str()); cta::exception::Errnum::throwOnNull(dir,"In LocalDirectory::getFilesName, failed to open directory at "+m_URL); - while((file = readdir(dir)) != NULL){ + while((file = readdir(dir)) != nullptr){ char *fileName = file->d_name; if(strcmp(fileName,".") && strcmp(fileName,"..")){ names.insert(std::string(file->d_name)); @@ -746,7 +746,7 @@ std::set<std::string> LocalDirectory::getFilesName(){ //============================================================================== // XROOT DIRECTORY -//============================================================================== +//============================================================================== XRootdDirectory::XRootdDirectory(const std::string& path):m_xrootFileSystem(path){ m_URL = path; m_truncatedDirectoryURL = cta::utils::extractPathFromXrootdPath(path); diff --git a/disk/RadosStriperPool.cpp b/disk/RadosStriperPool.cpp index 3155167714046c6f24e01756758e67c8cf20bc5f..038dacd74a81248e52ea279c0c013ea5ecda2aa8 100644 --- a/disk/RadosStriperPool.cpp +++ b/disk/RadosStriperPool.cpp @@ -35,7 +35,7 @@ private: }; } -namespace cta { +namespace cta { namespace disk { //------------------------------------------------------------------------------ @@ -79,7 +79,7 @@ libradosstriper::RadosStriper* RadosStriperPool::throwingGetStriper(const std::s // we need to create a new radosStriper, as the requested one is not there yet. // First find the user id (if any given) in the pool string // format is [<userid>@]<poolname> - const char* userId = NULL; + const char* userId = nullptr; size_t pos = userAtPool.find('@'); std::string user; std::string pool; @@ -94,9 +94,9 @@ libradosstriper::RadosStriper* RadosStriperPool::throwingGetStriper(const std::s ReleasingRados cluster; cta::exception::Errnum::throwOnReturnedErrno(cluster.init(userId), "In RadosStriperPool::throwingGetStriper(): failed to cluster.init(userId): "); - cta::exception::Errnum::throwOnReturnedErrno(cluster.conf_read_file(NULL), - "In RadosStriperPool::throwingGetStriper(): failed to cluster.conf_read_file(NULL): "); - cluster.conf_parse_env(NULL); + cta::exception::Errnum::throwOnReturnedErrno(cluster.conf_read_file(nullptr), + "In RadosStriperPool::throwingGetStriper(): failed to cluster.conf_read_file(nullptr): "); + cluster.conf_parse_env(nullptr); cta::exception::Errnum::throwOnReturnedErrno(cluster.connect(), "In RadosStriperPool::throwingGetStriper(): failed to cluster.connect(): "); librados::IoCtx ioctx; @@ -129,7 +129,7 @@ libradosstriper::RadosStriper* RadosStriperPool::getStriper(const std::string& u try { return throwingGetStriper(userAtPool); } catch (...) { - return NULL; + return nullptr; } } diff --git a/disk/RadosStriperPool.hpp b/disk/RadosStriperPool.hpp index c9ac6743a614d51e39cdbf2e46626501d64a1845..a5ff6b2ffa01c38788b9f5787e9ccfa6e9090d12 100644 --- a/disk/RadosStriperPool.hpp +++ b/disk/RadosStriperPool.hpp @@ -24,7 +24,7 @@ #include <radosstriper/libradosstriper.hpp> namespace cta { -namespace disk { +namespace disk { /** * Utility singleton managing the rados stripers connections by name. * The destructor will implicitly release the pool connections. @@ -43,7 +43,7 @@ public: /** * Get pointer to a connection to the rados user (or one from the cache). - * This function returns NULL in case of problem. + * This function returns nullptr in case of problem. */ libradosstriper::RadosStriper * getStriper(const std::string & userAtPool); diff --git a/eos_grpc_client/GrpcEndpoint.cpp b/eos_grpc_client/GrpcEndpoint.cpp index 5ce61669d3f042b498ce0b0b1379b17deb8981a7..549becb41d5d977abe41c0af47524c868d68781a 100644 --- a/eos_grpc_client/GrpcEndpoint.cpp +++ b/eos_grpc_client/GrpcEndpoint.cpp @@ -25,7 +25,7 @@ std::string eos::client::Endpoint::getPath(const std::string &diskFileId) const // diskFileId is sent to CTA as a uint64_t, but we store it as a decimal string, cf.: // XrdSsiCtaRequestMessage.cpp: request.diskFileID = std::to_string(notification.file().fid()); // Here we convert it back to make the namespace query: - uint64_t id = strtoull(diskFileId.c_str(), NULL, 0); + uint64_t id = strtoull(diskFileId.c_str(), nullptr, 0); if(id == 0) throw cta::exception::UserError("Invalid disk ID"); auto response = m_grpcClient->GetMD(eos::rpc::FILE, id, ""); @@ -60,4 +60,4 @@ void eos::client::Endpoint::getCurrentIds(uint64_t &cid, uint64_t &fid) const { eos::rpc::MDResponse eos::client::Endpoint::getMD(eos::rpc::TYPE type, uint64_t id, const std::string &path, bool showJson) const { return m_grpcClient->GetMD(type, id, path, showJson); -} \ No newline at end of file +} diff --git a/mediachanger/CommonMarshal.cpp b/mediachanger/CommonMarshal.cpp index 4f975480b63da8d652d27d7e8aee44469f33a7d6..33f42e4f65c0a2773961f58ae071a7a96c3efdbd 100644 --- a/mediachanger/CommonMarshal.cpp +++ b/mediachanger/CommonMarshal.cpp @@ -30,10 +30,10 @@ namespace mediachanger { //----------------------------------------------------------------------------- size_t marshal(char *const dst, const size_t dstLen, const MessageHeader &src) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal MessageHeader" - << ": Pointer to destination buffer is NULL"; + << ": Pointer to destination buffer is nullptr"; throw ex; } diff --git a/mediachanger/DismountCmdLine.cpp b/mediachanger/DismountCmdLine.cpp index 0982af255496d837076a4d551ba1788710309cf1..746d7876fd2a73f61e89c1fd79f61433e03296ba 100644 --- a/mediachanger/DismountCmdLine.cpp +++ b/mediachanger/DismountCmdLine.cpp @@ -41,9 +41,9 @@ cta::mediachanger::DismountCmdLine::DismountCmdLine(const int argc, m_driveLibrarySlot(0) { static struct option longopts[] = { - {"debug", 0, NULL, 'd'}, - {"help" , 0, NULL, 'h'}, - {NULL , 0, NULL, 0} + {"debug", 0, nullptr, 'd'}, + {"help" , 0, nullptr, 'h'}, + {nullptr , 0, nullptr, 0} }; // Prevent getopt() from printing an error message if it does not recognize @@ -51,7 +51,7 @@ cta::mediachanger::DismountCmdLine::DismountCmdLine(const int argc, opterr = 0; int opt = 0; - while((opt = getopt_long(argc, argv, ":dh", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, ":dh", longopts, nullptr)) != -1) { processOption(opt); } @@ -211,4 +211,3 @@ const cta::mediachanger::LibrarySlot &cta::mediachanger:: return *m_driveLibrarySlot; } - diff --git a/mediachanger/DismountCmdLineTest.cpp b/mediachanger/DismountCmdLineTest.cpp index 30f0164be02c84910247271860289638934522b1..63291ff947ba18c3957b693e957532baaa29655c 100644 --- a/mediachanger/DismountCmdLineTest.cpp +++ b/mediachanger/DismountCmdLineTest.cpp @@ -30,7 +30,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_mediachanger_DismountCmdLineTest, copy_constructor) { args->argv[0] = dupString("cta-mediachanger-dismount"); args->argv[1] = dupString("vid"); args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; + args->argv[3] = nullptr; DismountCmdLine cmdLine1(args->argc, args->argv); ASSERT_FALSE(cmdLine1.getHelp()); @@ -102,7 +102,7 @@ TEST_F(cta_mediachanger_DismountCmdLineTest, assignment) { args1->argv[0] = dupString("cta-mediachanger-dismount"); args1->argv[1] = dupString("vid"); args1->argv[2] = dupString("smc1"); - args1->argv[3] = NULL; + args1->argv[3] = nullptr; DismountCmdLine cmdLine1(args1->argc, args1->argv); ASSERT_FALSE(cmdLine1.getHelp()); @@ -117,7 +117,7 @@ TEST_F(cta_mediachanger_DismountCmdLineTest, assignment) { args2->argv[0] = dupString("cta-mediachanger-dismount"); args2->argv[1] = dupString("vid"); args2->argv[2] = dupString("smc2"); - args2->argv[3] = NULL; + args2->argv[3] = nullptr; DismountCmdLine cmdLine2(args2->argc, args2->argv); ASSERT_FALSE(cmdLine2.getHelp()); @@ -148,7 +148,7 @@ TEST_F(cta_mediachanger_DismountCmdLineTest, scsi) { args->argv[0] = dupString("cta-mediachanger-dismount"); args->argv[1] = dupString("vid"); args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; + args->argv[3] = nullptr; std::unique_ptr<DismountCmdLine> cmdLine; ASSERT_NO_THROW(cmdLine.reset(new DismountCmdLine(args->argc, args->argv))); diff --git a/mediachanger/MountCmdLine.cpp b/mediachanger/MountCmdLine.cpp index 8dcbe14bb250f50b86c32177910783358c1a7e91..c30fcfac3feb74abf89987db3d61bba9c0444d77 100644 --- a/mediachanger/MountCmdLine.cpp +++ b/mediachanger/MountCmdLine.cpp @@ -42,10 +42,10 @@ cta::mediachanger::MountCmdLine::MountCmdLine(const int argc, m_driveLibrarySlot(0) { static struct option longopts[] = { - {"debug" , 0, NULL, 'd'}, - {"help" , 0, NULL, 'h'}, - {"readonly" , 0, NULL, 'r'}, - {NULL , 0, NULL, 0} + {"debug" , 0, nullptr, 'd'}, + {"help" , 0, nullptr, 'h'}, + {"readonly" , 0, nullptr, 'r'}, + {nullptr , 0, nullptr, 0} }; // Prevent getopt() from printing an error message if it does not recognize @@ -53,7 +53,7 @@ cta::mediachanger::MountCmdLine::MountCmdLine(const int argc, opterr = 0; int opt = 0; - while((opt = getopt_long(argc, argv, ":dhr", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, ":dhr", longopts, nullptr)) != -1) { processOption(opt); } diff --git a/mediachanger/MountCmdLineTest.cpp b/mediachanger/MountCmdLineTest.cpp index c427abae03bddcd468075b30def5061555732679..4626660be9c1a2a871f22ea248a2836b71c76adc 100644 --- a/mediachanger/MountCmdLineTest.cpp +++ b/mediachanger/MountCmdLineTest.cpp @@ -30,7 +30,7 @@ protected: struct Argcv { int argc; char **argv; - Argcv(): argc(0), argv(NULL) { + Argcv(): argc(0), argv(nullptr) { } }; typedef std::list<Argcv*> ArgcvList; @@ -75,7 +75,7 @@ TEST_F(cta_mediachanger_MountCmdLineTest, copy_constructor) { args->argv[0] = dupString("cta-mediachanger-mount"); args->argv[1] = dupString("vid"); args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; + args->argv[3] = nullptr; MountCmdLine cmdLine1(args->argc, args->argv); ASSERT_FALSE(cmdLine1.getHelp()); @@ -102,7 +102,7 @@ TEST_F(cta_mediachanger_MountCmdLineTest, assignment) { args1->argv[0] = dupString("cta-mediachanger-mount"); args1->argv[1] = dupString("vid"); args1->argv[2] = dupString("smc1"); - args1->argv[3] = NULL; + args1->argv[3] = nullptr; MountCmdLine cmdLine1(args1->argc, args1->argv); ASSERT_FALSE(cmdLine1.getHelp()); @@ -118,7 +118,7 @@ TEST_F(cta_mediachanger_MountCmdLineTest, assignment) { args2->argv[0] = dupString("cta-mediachanger-mount"); args2->argv[1] = dupString("vid"); args2->argv[2] = dupString("smc2"); - args2->argv[3] = NULL; + args2->argv[3] = nullptr; MountCmdLine cmdLine2(args2->argc, args2->argv); ASSERT_FALSE(cmdLine2.getHelp()); @@ -152,7 +152,7 @@ TEST_F(cta_mediachanger_MountCmdLineTest, scsi) { args->argv[0] = dupString("cta-mediachanger-mount"); args->argv[1] = dupString("vid"); args->argv[2] = dupString("smc1"); - args->argv[3] = NULL; + args->argv[3] = nullptr; std::unique_ptr<MountCmdLine> cmdLine; ASSERT_NO_THROW(cmdLine.reset(new MountCmdLine(args->argc, args->argv))); diff --git a/mediachanger/RmcMarshal.cpp b/mediachanger/RmcMarshal.cpp index 24b96717204331d37291558a195fb4b7f177af34..3e781b3a81bbd501cca53755c64380dd222b0eb0 100644 --- a/mediachanger/RmcMarshal.cpp +++ b/mediachanger/RmcMarshal.cpp @@ -30,10 +30,10 @@ namespace mediachanger { size_t marshal(char *const dst, const size_t dstLen, const RmcMountMsgBody &src) { const char *task = "marshal RmcMountMsgBody"; - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to " << task << - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -84,9 +84,9 @@ size_t marshal(char *const dst, const size_t dstLen, const RmcMountMsgBody &src) marshalString(src.vid, p); marshalUint16(src.side, p); marshalUint16(src.drvOrd, p); - } catch(cta::exception::Exception &ne) { + } catch(cta::exception::Exception &ne) { cta::exception::Exception ex; - ex.getMessage() << "Failed to " << task << ": Failed to marshal body: " + ex.getMessage() << "Failed to " << task << ": Failed to marshal body: " << ne.getMessage().str(); throw ex; } @@ -131,10 +131,10 @@ void unmarshal(const char * &src, size_t &srcLen, RmcMountMsgBody &dst) { size_t marshal(char *const dst, const size_t dstLen, const RmcUnmountMsgBody &src) { const char *const task = "marshal RmcUnmountMsgBody"; - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to " << task << - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } diff --git a/mediachanger/io.cpp b/mediachanger/io.cpp index 663c45878bf678b783a8d2e156b42204ee4662ff..95fa9ee47671f678f7c31d45159826b1ec937b26 100644 --- a/mediachanger/io.cpp +++ b/mediachanger/io.cpp @@ -124,7 +124,7 @@ int createListenerSock( SmartFd sock(socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)); if(sock.get() < 0) { cta::exception::Exception ex; - ex.getMessage() << ": Failed to create socket: " + ex.getMessage() << ": Failed to create socket: " << cta::utils::errnoToString(errno); throw ex; } @@ -291,7 +291,7 @@ int acceptConnection(const int listenSocketFd, throw ex; } - const time_t startTime = time(NULL); + const time_t startTime = time(nullptr); pollfd pollFd; pollFd.fd = listenSocketFd; @@ -314,7 +314,7 @@ int acceptConnection(const int listenSocketFd, case -1: // poll() encountered an error // If poll() was interrupted if(pollErrno == EINTR) { - const time_t remainingTime = timeout - (time(NULL) - startTime); + const time_t remainingTime = timeout - (time(nullptr) - startTime); cta::exception::AcceptConnectionInterrupted ex(remainingTime); @@ -648,7 +648,7 @@ void readBytes( "In io::readBytes: Invalid timeout value: " << timeout; throw ex; } - + cta::utils::Timer timer; size_t bytesRemaining = nbBytes; char * readPtr = buf; @@ -660,7 +660,7 @@ void readBytes( pollDescr.revents = 0; int pollRet = poll(&pollDescr, 1, (timeout * 1000) - (timer.usecs()/1000)); cta::exception::Errnum::throwOnMinusOne(pollRet, "In io::readBytes: failed to poll socket"); - if (!pollRet) + if (!pollRet) throw cta::exception::Exception("In io::readBytes: timeout"); if (pollRet != 1) { std::stringstream err; @@ -705,14 +705,14 @@ void writeBytes( ": socketFd=" << socketFd; throw ex; } - + if (timeout < 0) { cta::exception::InvalidArgument ex; ex.getMessage() << "In io::writeBytes: Invalid timeout value: " << timeout; throw ex; } - + cta::utils::Timer timer; size_t bytesRemaining = nbBytes; char * writePtr = buf; @@ -724,7 +724,7 @@ void writeBytes( pollDescr.revents = 0; int pollRet = poll(&pollDescr, 1, (timeout * 1000) - (timer.usecs()/1000)); cta::exception::Errnum::throwOnMinusOne(pollRet, "In io::writeBytes: failed to poll socket"); - if (!pollRet) + if (!pollRet) throw cta::exception::Exception("In io::writeBytes: timeout"); if (pollRet != 1) { std::stringstream err; @@ -750,7 +750,7 @@ void writeBytes( //------------------------------------------------------------------------------ // getAddrInfoErrorString -// +// // Helper function used to know which string is associated with a specific errno // returned by getaddrinfo. This function is needed because the standard one // (gai_strerror) is not thread-safe on all systems. @@ -831,8 +831,8 @@ int connectWithTimeout( memset(&hints, '\0', sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; - - struct addrinfo *res = NULL; + + struct addrinfo *res = nullptr; { const int rc = getaddrinfo(hostName.c_str(), portStream.str().c_str(), &hints, &res); // If getaddrinfo() returned a negative value @@ -855,7 +855,7 @@ int connectWithTimeout( int protocol = res->ai_protocol; socklen_t length = res->ai_addrlen; freeaddrinfo(res); - + return connectWithTimeout(AF_INET, SOCK_STREAM, protocol, (struct sockaddr *)(&s_in), length, timeout); } catch(cta::exception::Exception &ce) { @@ -938,7 +938,7 @@ int connectWithTimeout( // "operation in progress" when trying to start to connect if(EINPROGRESS != connectErrno) { cta::exception::Exception ex; - ex.getMessage() << "Call to connect() failed: " + ex.getMessage() << "Call to connect() failed: " << cta::utils::errnoToString(connectErrno); throw ex; } @@ -981,13 +981,13 @@ int connectWithTimeout( int sockoptError = 0; socklen_t sockoptErrorLen = sizeof(sockoptError); cta::exception::Errnum::throwOnMinusOne( - getsockopt(smartSock.get(), SOL_SOCKET, SO_ERROR, &sockoptError, - &sockoptErrorLen), + getsockopt(smartSock.get(), SOL_SOCKET, SO_ERROR, &sockoptError, + &sockoptErrorLen), "In io::connectWithTimeout: failed to getsockopt: "); if(0 != sockoptError) { // BSD cta::exception::Exception ex; - ex.getMessage() - << "In io::connectWithTimeout: Connection did not complete successfully: " + ex.getMessage() + << "In io::connectWithTimeout: Connection did not complete successfully: " << cta::utils::errnoToString(sockoptError); throw ex; } @@ -1005,10 +1005,10 @@ int connectWithTimeout( //------------------------------------------------------------------------------ void marshalUint8(const uint8_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal uint8_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1021,10 +1021,10 @@ void marshalUint8(const uint8_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalInt16(const int16_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal int16_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1038,10 +1038,10 @@ void marshalInt16(const int16_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalUint16(const uint16_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal uint16_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1055,10 +1055,10 @@ void marshalUint16(const uint16_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalInt32(const int32_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal int32_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1072,10 +1072,10 @@ void marshalInt32(const int32_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalUint32(const uint32_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal uint32_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1089,10 +1089,10 @@ void marshalUint32(const uint32_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalUint64(const uint64_t src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal uint64_t" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1115,10 +1115,10 @@ void marshalUint64(const uint64_t src, char * &dst) { //------------------------------------------------------------------------------ void marshalString(const std::string &src, char * &dst) { - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to marshal string" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } @@ -1133,10 +1133,10 @@ void marshalString(const std::string &src, char * &dst) { void unmarshalUint8(const char * &src, size_t &srcLen, uint8_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal uint8_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1159,10 +1159,10 @@ void unmarshalUint8(const char * &src, size_t &srcLen, void unmarshalInt16(const char * &src, size_t &srcLen, int16_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal int16_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1187,10 +1187,10 @@ void unmarshalInt16(const char * &src, size_t &srcLen, void unmarshalUint16(const char * &src, size_t &srcLen, uint16_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal uint16_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1215,10 +1215,10 @@ void unmarshalUint16(const char * &src, size_t &srcLen, void unmarshalUint32(const char * &src, size_t &srcLen, uint32_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal uint32_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1243,10 +1243,10 @@ void unmarshalUint32(const char * &src, size_t &srcLen, void unmarshalInt32(const char * &src, size_t &srcLen, int32_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal int32_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1271,10 +1271,10 @@ void unmarshalInt32(const char * &src, size_t &srcLen, void unmarshalUint64(const char * &src, size_t &srcLen, uint64_t &dst) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal uint64_t" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1305,10 +1305,10 @@ void unmarshalString(const char * &src, size_t &srcLen, char *dst, const size_t dstLen) { - if(src == NULL) { + if(src == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal string" - ": Pointer to source buffer is NULL"; + ": Pointer to source buffer is nullptr"; throw ex; } @@ -1319,10 +1319,10 @@ void unmarshalString(const char * &src, throw ex; } - if(dst == NULL) { + if(dst == nullptr) { cta::exception::Exception ex; ex.getMessage() << "Failed to unmarshal string" - ": Pointer to destination buffer is NULL"; + ": Pointer to destination buffer is nullptr"; throw ex; } diff --git a/objectstore/AlgorithmsTest.cpp b/objectstore/AlgorithmsTest.cpp index 9cbfea1c96972d09d4fa75faaaf413c3576f2057..07edd30bc8d092bda5ce3e7c64b966edc645ca54 100644 --- a/objectstore/AlgorithmsTest.cpp +++ b/objectstore/AlgorithmsTest.cpp @@ -176,7 +176,7 @@ TEST(ObjectStore, ArchiveQueueAlgorithms) { re.insert(); // Create the agent register EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -258,7 +258,7 @@ TEST(ObjectStore, ArchiveQueueAlgorithmsWithDeletedJobsInQueue) { re.insert(); // Create the agent register EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -375,7 +375,7 @@ TEST(ObjectStore, RetrieveQueueAlgorithms) { re.initialize(); re.insert(); // Create the agent register - EntryLogSerDeser el("user0", "unittesthost", time(NULL)); + EntryLogSerDeser el("user0", "unittesthost", time(nullptr)); ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); re.addOrGetAgentRegisterPointerAndCommit(agentRef2, el, lc); @@ -464,7 +464,7 @@ TEST(ObjectStore, RetrieveQueueAlgorithmsUpdatesOldestJobQueueTime) { re.initialize(); re.insert(); // Create the agent register - cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(NULL)); + cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -553,7 +553,7 @@ TEST(ObjectStore, ArchiveQueueAlgorithmsUpdatesOldestJobQueueTime) { re.initialize(); re.insert(); // Create the agent register - cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(NULL)); + cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); diff --git a/objectstore/BackendPopulator.cpp b/objectstore/BackendPopulator.cpp index 84c795d4d055ebc37ea7ad8e340647c5d7e1a8b6..dc5b1769f28bc86b84df0a8238535af1fc6837b1 100644 --- a/objectstore/BackendPopulator.cpp +++ b/objectstore/BackendPopulator.cpp @@ -25,12 +25,12 @@ namespace cta { namespace objectstore { //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ -BackendPopulator::BackendPopulator(cta::objectstore::Backend & be, +BackendPopulator::BackendPopulator(cta::objectstore::Backend & be, const std::string &agentType, const cta::log::LogContext & lc): m_backend(be), m_agentReference(agentType, lc.logger()), m_lc(lc) { cta::objectstore::RootEntry re(m_backend); re.fetchNoLock(); - cta::objectstore::EntryLogSerDeser cl("user0", "systemhost", time(NULL)); + cta::objectstore::EntryLogSerDeser cl("user0", "systemhost", time(nullptr)); // We might have to create the agent register (but this is unlikely) log::LogContext lc2(lc); try { @@ -104,4 +104,4 @@ void BackendPopulator::leaveNonEmptyAgentsBehind() { } -}} \ No newline at end of file +}} diff --git a/objectstore/BackendRados.cpp b/objectstore/BackendRados.cpp index 849e551d1fabcc48fde15278bb2f39704201cefb..1a37b24e73d5abc6a2a279b091b4021baad604bc 100644 --- a/objectstore/BackendRados.cpp +++ b/objectstore/BackendRados.cpp @@ -93,11 +93,11 @@ m_user(userId), m_pool(pool), m_namespace(radosNameSpace), m_cluster(), m_radosC "In BackendRados::BackendRados, failed to m_cluster.init"); try { RadosTimeoutLogger rtl; - cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([&]() { return -m_cluster.conf_read_file(NULL);}, + cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([&]() { return -m_cluster.conf_read_file(nullptr);}, "In BackendRados::BackendRados, failed to m_cluster.conf_read_file"); rtl.logIfNeeded("In BackendRados::BackendRados(): m_cluster.conf_read_file()", "no object"); rtl.reset(); - cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([&](){ return -m_cluster.conf_parse_env(NULL);}, + cta::exception::Errnum::throwOnReturnedErrnoOrThrownStdException([&](){ return -m_cluster.conf_parse_env(nullptr);}, "In BackendRados::BackendRados, failed to m_cluster.conf_parse_env"); rtl.logIfNeeded("In BackendRados::BackendRados(): m_cluster.conf_parse_env()", "no object"); rtl.reset(); diff --git a/objectstore/GarbageCollectorTest.cpp b/objectstore/GarbageCollectorTest.cpp index 6f83742bf3915f5ac29ec0ccd7b727c8ec2ddb7b..6d93c94864883099a105694cc179d84b7c606c38 100644 --- a/objectstore/GarbageCollectorTest.cpp +++ b/objectstore/GarbageCollectorTest.cpp @@ -63,7 +63,7 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -119,7 +119,7 @@ TEST(ObjectStore, GarbageCollectorRegister) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -183,7 +183,7 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -247,7 +247,7 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); rel.release(); @@ -309,7 +309,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { re.initialize(); re.insert(); // Create the agent register - cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(NULL)); + cta::objectstore::EntryLogSerDeser el("user0", "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -396,7 +396,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { policy.archiveMinRequestAge = 0; policy.archivePriority = 1; std::list <cta::objectstore::ArchiveQueue::JobToAdd> jta; - jta.push_back({jd, ar.getAddressIfSet(), ar.getArchiveFile().archiveFileID, 1000U+pass, policy, time(NULL)}); + jta.push_back({jd, ar.getAddressIfSet(), ar.getArchiveFile().archiveFileID, 1000U+pass, policy, time(nullptr)}); aq.addJobsAndCommit(jta, agentRef, lc); ar.setJobOwner(1, aq.getAddressIfSet()); ar.commit(); @@ -416,7 +416,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { policy.archiveMinRequestAge = 0; policy.archivePriority = 1; std::list <cta::objectstore::ArchiveQueue::JobToAdd> jta; - jta.push_back({jd, ar.getAddressIfSet(), ar.getArchiveFile().archiveFileID, 1000+pass, policy, time(NULL)}); + jta.push_back({jd, ar.getAddressIfSet(), ar.getArchiveFile().archiveFileID, 1000+pass, policy, time(nullptr)}); aq.addJobsAndCommit(jta, agentRef, lc); ar.setJobOwner(2, aq.getAddressIfSet()); ar.commit(); @@ -499,7 +499,7 @@ TEST(ObjectStore, GarbageCollectorRetrieveRequest) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -687,7 +687,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestPending) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -769,7 +769,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestToExpand) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -850,7 +850,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandNotFinished) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -933,7 +933,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandFinished) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -1042,7 +1042,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestStarting) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -1121,7 +1121,7 @@ TEST(ObjectStore, GarbageCollectorRetrieveAllStatusesAndQueues) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -1590,7 +1590,7 @@ TEST(ObjectStore, GarbageCollectorRetrieveRequestRepackDisabledTape) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -1751,7 +1751,7 @@ TEST(ObjectStore, GarbageCollectorArchiveAllStatusesAndQueues) { re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); diff --git a/objectstore/ObjectOps.hpp b/objectstore/ObjectOps.hpp index a207d121b4cc1433e0ab928dc52aea66269beff1..a973242a59b623ee911fb771e1c29e2b73fe44e5 100644 --- a/objectstore/ObjectOps.hpp +++ b/objectstore/ObjectOps.hpp @@ -62,7 +62,7 @@ class ObjectOpsBase { friend ContainerTraits<ArchiveQueue,ArchiveQueueFailed>; friend ContainerTraits<ArchiveQueue,ArchiveQueueToTransferForRepack>; friend ContainerTraits<ArchiveQueue,ArchiveQueueToReportToRepackForFailure>; - friend ContainerTraits<ArchiveQueue,ArchiveQueueToReportToRepackForSuccess>; + friend ContainerTraits<ArchiveQueue,ArchiveQueueToReportToRepackForSuccess>; friend ContainerTraits<RetrieveQueue,RetrieveQueueToTransfer>; friend ContainerTraits<RetrieveQueue,RetrieveQueueToReportForUser>; friend ContainerTraits<RetrieveQueue,RetrieveQueueFailed>; @@ -72,64 +72,64 @@ class ObjectOpsBase { friend ContainerTraits<RepackQueue,RepackQueuePending>; friend ContainerTraits<RepackQueue,RepackQueueToExpand>; protected: - ObjectOpsBase(Backend & os): m_nameSet(false), m_objectStore(os), + ObjectOpsBase(Backend & os): m_nameSet(false), m_objectStore(os), m_headerInterpreted(false), m_payloadInterpreted(false), m_existingObject(false), m_locksCount(0), m_locksForWriteCount(0) {} - + virtual ~ObjectOpsBase(); public: CTA_GENERATE_EXCEPTION_CLASS(AddressNotSet); - CTA_GENERATE_EXCEPTION_CLASS(NotLocked); + CTA_GENERATE_EXCEPTION_CLASS(NotLocked); CTA_GENERATE_EXCEPTION_CLASS(WrongType); CTA_GENERATE_EXCEPTION_CLASS(NotNewObject); CTA_GENERATE_EXCEPTION_CLASS(NewObject); CTA_GENERATE_EXCEPTION_CLASS(NotFetched); - CTA_GENERATE_EXCEPTION_CLASS(NotInitialized); + CTA_GENERATE_EXCEPTION_CLASS(NotInitialized); CTA_GENERATE_EXCEPTION_CLASS(AddressAlreadySet); CTA_GENERATE_EXCEPTION_CLASS(InvalidAddress); CTA_GENERATE_EXCEPTION_CLASS(FailedToSerialize); CTA_GENERATE_EXCEPTION_CLASS(StillLocked); protected: void checkHeaderWritable() { - if (!m_headerInterpreted) + if (!m_headerInterpreted) throw NotFetched("In ObjectOps::checkHeaderWritable: header not yet fetched or initialized"); checkWritable(); } - + void checkHeaderReadable() { - if (!m_headerInterpreted) + if (!m_headerInterpreted) throw NotFetched("In ObjectOps::checkHeaderReadable: header not yet fetched or initialized"); checkReadable(); } - + void checkPayloadWritable() { - if (!m_payloadInterpreted) + if (!m_payloadInterpreted) throw NotFetched("In ObjectOps::checkPayloadWritable: header not yet fetched or initialized"); checkWritable(); } - + void checkPayloadReadable() { - if (!m_payloadInterpreted) + if (!m_payloadInterpreted) throw NotFetched("In ObjectOps::checkPayloadReadable: header not yet fetched or initialized"); checkReadable(); } - + void checkWritable() { if (m_existingObject && !m_locksForWriteCount) throw NotLocked("In ObjectOps::checkWritable: object not locked for write"); if (m_existingObject && !m_exclusiveLock && !m_lockForSubObject) throw exception::Exception("In ObjectOps::checkWritable: missing reference to exclusive lock"); } - + void checkReadable() { // We could still read from a fresh, not yet inserted object. if (m_existingObject && (!m_locksCount && !m_noLock)) throw NotLocked("In ObjectOps::checkReadable: object not locked"); } - + public: - + void setAddress(const std::string & name) { if (m_nameSet) throw AddressAlreadySet("In ObjectOps::setAddress(): trying to overwrite an already set name"); @@ -138,7 +138,7 @@ public: m_name = name; m_nameSet = true; } - + void resetAddress() { if (m_locksCount || m_locksForWriteCount) { throw StillLocked("In ObjectOps::resetAddress: reset the address of a locked object"); @@ -149,14 +149,14 @@ public: m_payloadInterpreted = false; m_existingObject = false; } - + std::string & getAddressIfSet() { if (!m_nameSet) { throw AddressNotSet("In ObjectOpsBase::getNameIfSet: name not set yet"); } return m_name; } - + void remove () { checkWritable(); m_objectStore.remove(getAddressIfSet()); @@ -164,28 +164,28 @@ public: m_headerInterpreted = false; m_payloadInterpreted = false; } - + void resetValues () { m_existingObject = false; m_headerInterpreted = false; m_payloadInterpreted = false; } - + void setOwner(const std::string & owner) { checkHeaderWritable(); m_header.set_owner(owner); } - + std::string getOwner() { checkHeaderReadable(); return m_header.owner(); } - + void setBackupOwner(const std::string & owner) { checkHeaderWritable(); m_header.set_backupowner(owner); } - + std::string getBackupOwner() { checkHeaderReadable(); return m_header.backupowner(); @@ -216,25 +216,25 @@ public: checkLocked(); releaseIfNeeded(); } - + bool isLocked() { return m_locked; } - + /** * Virtual function (implemented differently in shared and exclusive locks), * marking the object as locked. * @param objectOps pointer to the ObjectOpsBase. */ virtual void setObjectLocked(ObjectOpsBase * objectOps) = 0; - + /** * Virtual function (implemented differently in shared and exclusive locks), * marking the object as unlocked. * @param objectOps pointer to the ObjectOpsBase. */ virtual void setObjectUnlocked(ObjectOpsBase * objectOps) = 0; - + /** * Expand the scope of the current lock to a sub object, which will also be covered * by this lock. This will allow the sub object to benefit from the same protection @@ -253,7 +253,7 @@ public: // Add a reference to the object. m_subObjectsOps.push_back(oob); } - + /** Move the locked object reference to a new one. This is done when the locked * object is a GenericObject and the caller instantiated a derived object from * it. The lock follows the move. @@ -276,12 +276,12 @@ public: oldObject.m_lockForSubObject = nullptr; oldObject.m_noLock=false; } - + /** - * + * * @param subObject */ - + /** * Dereference a sub object at destruction time * @param subObject @@ -289,18 +289,18 @@ public: void dereferenceSubObject(ObjectOpsBase & subObject) { m_subObjectsOps.remove(&subObject); } - + virtual ~ScopedLock() { // Each child class will have to call releaseIfNeeded() in their own destructor // as it relies on pure virtual members of this base class. } - + CTA_GENERATE_EXCEPTION_CLASS(AlreadyLocked); CTA_GENERATE_EXCEPTION_CLASS(NotLocked); CTA_GENERATE_EXCEPTION_CLASS(MissingAddress); - + protected: - ScopedLock(): m_objectOps(NULL), m_locked(false) {} + ScopedLock(): m_objectOps(nullptr), m_locked(false) {} std::unique_ptr<Backend::ScopedLock> m_lock; ObjectOpsBase * m_objectOps; std::list <ObjectOpsBase *> m_subObjectsOps; @@ -317,17 +317,17 @@ protected: // By default we deal with the main object. if (!oob) oob = m_objectOps; if (!oob) { - throw MissingAddress("In ScopedLock::checkAddressSet: trying to lock a NULL object"); + throw MissingAddress("In ScopedLock::checkAddressSet: trying to lock a nullptr object"); } else if (!oob->m_nameSet || oob->m_name.empty()) { throw MissingAddress("In ScopedLock::checkAddressSet: trying to lock an object without address"); } } virtual void releaseIfNeeded() { if(!m_locked) return; - m_lock.reset(NULL); + m_lock.reset(nullptr); m_locked = false; setObjectUnlocked(m_objectOps); - // Releasing a lock voids the object content in memory as stored object can now change. + // Releasing a lock voids the object content in memory as stored object can now change. m_objectOps->m_payloadInterpreted = false; // Apply the same to sub objects for (auto & oob: m_subObjectsOps) { @@ -336,14 +336,14 @@ protected: } } }; - + class ScopedSharedLock: public ScopedLock { public: ScopedSharedLock() {} ScopedSharedLock(ObjectOpsBase & oo) { lock(oo); } - + void setObjectLocked(ObjectOpsBase* objectOps) override final { objectOps->m_locksCount++; } @@ -351,7 +351,7 @@ public: void setObjectUnlocked(ObjectOpsBase* objectOps) override final { objectOps->m_locksCount--; } - + void lock(ObjectOpsBase & oo) { checkNotLocked(); m_objectOps = & oo; @@ -360,7 +360,7 @@ public: ScopedSharedLock::setObjectLocked(m_objectOps); m_locked = true; } - + virtual ~ScopedSharedLock() { releaseIfNeeded(); } @@ -373,12 +373,12 @@ public: ScopedExclusiveLock(ObjectOpsBase & oo, uint64_t timeout_us = 0) { lock(oo, timeout_us); } - + void setObjectLocked(ObjectOpsBase* objectOps) override { objectOps->m_locksCount++; objectOps->m_locksForWriteCount++; } - + void setObjectUnlocked(ObjectOpsBase* objectOps) override { objectOps->m_locksCount--; objectOps->m_locksForWriteCount--; @@ -393,7 +393,7 @@ public: m_objectOps->m_exclusiveLock = this; m_locked = true; } - + /** Move the locked object reference to a new one. This is done when the locked * object is a GenericObject and the caller instantiated a derived object from * it. The lock follows the move. @@ -414,7 +414,7 @@ public: } ScopedLock::transfer(*m_objectOps, newObject); } - + virtual ~ScopedExclusiveLock() { releaseIfNeeded(); } @@ -427,11 +427,11 @@ protected: ObjectOps(Backend & os, const std::string & name): ObjectOpsBase(os) { setAddress(name); } - + ObjectOps(Backend & os): ObjectOpsBase(os) {} - + virtual ~ObjectOps() {} - + public: void fetch() { // Check that the object is locked, one way or another @@ -439,12 +439,12 @@ public: throw NotLocked("In ObjectOps::fetch(): object not locked"); fetchBottomHalf(); } - + void fetchNoLock() { m_noLock = true; fetchBottomHalf(); } - + void fetchBottomHalf() { m_existingObject = true; // Get the header from the object store @@ -452,7 +452,7 @@ public: // Interpret the data getPayloadFromHeader(); } - + class AsyncLockfreeFetcher { friend class ObjectOps; AsyncLockfreeFetcher(ObjectOps & obj): m_obj(obj) {} @@ -471,14 +471,14 @@ public: std::unique_ptr<Backend::AsyncLockfreeFetcher> m_asyncLockfreeFetcher; }; friend AsyncLockfreeFetcher; - + AsyncLockfreeFetcher * asyncLockfreeFetch () { std::unique_ptr<AsyncLockfreeFetcher> ret; ret.reset(new AsyncLockfreeFetcher(*this)); ret->m_asyncLockfreeFetcher.reset(m_objectStore.asyncLockfreeFetch(getAddressIfSet())); return ret.release(); } - + class AsyncInserter { friend class ObjectOps; AsyncInserter(ObjectOps & obj): m_obj(obj) {} @@ -492,7 +492,7 @@ public: std::unique_ptr<Backend::AsyncCreator> m_asyncCreator; }; friend AsyncInserter; - + AsyncInserter * asyncInsert() { std::unique_ptr<AsyncInserter> ret; ret.reset(new AsyncInserter(*this)); @@ -511,10 +511,10 @@ public: ret->m_asyncCreator.reset(m_objectStore.asyncCreate(getAddressIfSet(), m_header.SerializeAsString())); return ret.release(); } - + void commit() { checkPayloadWritable(); - if (!m_existingObject) + if (!m_existingObject) throw NewObject("In ObjectOps::commit: trying to update a new object"); // Serialise the payload into the header try { @@ -526,16 +526,16 @@ public: // Write the object m_objectStore.atomicOverwrite(getAddressIfSet(), m_header.SerializeAsString()); } - + CTA_GENERATE_EXCEPTION_CLASS(WrongTypeForGarbageCollection); /** * This function should be overloaded in the inheriting classes */ virtual void garbageCollect(const std::string &presumedOwner, AgentReference & agentReference, log::LogContext & lc, cta::catalogue::Catalogue & catalogue) = 0; - + protected: - + virtual void getPayloadFromHeader () { if (!m_payload.ParseFromString(m_header.payload())) { // Use the tolerant parser to assess the situation. @@ -546,14 +546,14 @@ protected: CryptoPP::StringSource ss1(m_header.payload(), true, new CryptoPP::Base64Encoder( new CryptoPP::StringSink(payloadBase64), noNewLineInBase64Output)); - throw cta::exception::Exception(std::string("In <ObjectOps") + typeid(PayloadType).name() + - ">::getPayloadFromHeader(): could not parse payload: " + m_header.InitializationErrorString() + - " size=" + std::to_string(m_header.payload().size()) + " data(b64)=\"" + + throw cta::exception::Exception(std::string("In <ObjectOps") + typeid(PayloadType).name() + + ">::getPayloadFromHeader(): could not parse payload: " + m_header.InitializationErrorString() + + " size=" + std::to_string(m_header.payload().size()) + " data(b64)=\"" + payloadBase64 + "\""); } m_payloadInterpreted = true; } - + virtual void getHeaderFromObjectData(const std::string & objData) { if (!m_header.ParseFromString(objData)) { // Use the tolerant parser to assess the situation. @@ -564,9 +564,9 @@ protected: CryptoPP::StringSource ss1(objData, true, new CryptoPP::Base64Encoder( new CryptoPP::StringSink(objDataBase64), noNewLineInBase64Output)); - throw cta::exception::Exception(std::string("In ObjectOps<") + typeid(PayloadType).name() + - ">::getHeaderFromObjectData(): could not parse header: " + m_header.InitializationErrorString() + - " size=" + std::to_string(objData.size()) + " data(b64)=\"" + + throw cta::exception::Exception(std::string("In ObjectOps<") + typeid(PayloadType).name() + + ">::getHeaderFromObjectData(): could not parse header: " + m_header.InitializationErrorString() + + " size=" + std::to_string(objData.size()) + " data(b64)=\"" + objDataBase64 + "\""); } if (m_header.type() != payloadTypeId) { @@ -582,7 +582,7 @@ protected: auto objData=m_objectStore.read(getAddressIfSet()); getHeaderFromObjectData(objData); } - + public: /** * Fill up the header and object with its default contents @@ -596,7 +596,7 @@ public: m_header.set_backupowner(""); m_headerInterpreted = true; } - + void insert() { // Check that we are not dealing with an existing object if (m_existingObject) @@ -611,30 +611,30 @@ public: m_objectStore.create(getAddressIfSet(), m_header.SerializeAsString()); m_existingObject = true; } - + bool exists() { return m_objectStore.exists(getAddressIfSet()); } - + private: template <class ChildType> void writeChild (const std::string & name, ChildType & val) { m_objectStore.create(name, val.SerializeAsString()); } - + void removeOther(const std::string & name) { m_objectStore.remove(name); } - + std::string selfName() { if(!m_nameSet) throw AddressNotSet("In ObjectOps<>::updateFromObjectStore: name not set"); return m_name; } - + Backend & objectStore() { return m_objectStore; } - + protected: static const serializers::ObjectType payloadTypeId = PayloadTypeId; PayloadType m_payload; diff --git a/objectstore/RootEntryTest.cpp b/objectstore/RootEntryTest.cpp index 1732928f88dea6798318a5e8c33d98837a8e7445..a1b0b2e8838537592c37850397e60e7c2b2f202e 100644 --- a/objectstore/RootEntryTest.cpp +++ b/objectstore/RootEntryTest.cpp @@ -60,7 +60,7 @@ TEST(ObjectStore, RootEntryBasicAccess) { cta::objectstore::Agent agent(agentRef.getAgentAddress(), be); re.fetch(); cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el, lc); ASSERT_NO_THROW(re.getAgentRegisterAddress()); re.commit(); @@ -79,7 +79,7 @@ TEST(ObjectStore, RootEntryArchiveQueues) { using cta::common::dataStructures::JobQueueType; cta::objectstore::BackendVFS be; cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::log::DummyLogger dl("dummy", "dummyLogger"); cta::log::LogContext lc(dl); cta::objectstore::AgentReference agr("UnitTests", dl); @@ -147,7 +147,7 @@ TEST(ObjectStore, RootEntryDriveRegister) { re.insert(); } cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::log::DummyLogger dl("dummy", "dummyLogger"); cta::log::LogContext lc(dl); cta::objectstore::AgentReference agr("UnitTests", dl); @@ -203,7 +203,7 @@ TEST(ObjectStore, RootEntryAgentRegister) { re.insert(); } cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::log::DummyLogger dl("dummy", "dummyLogger"); cta::log::LogContext lc(dl); cta::objectstore::AgentReference agr("UnitTests", dl); @@ -253,7 +253,7 @@ TEST(ObjectStore, RootEntrySchedulerGlobalLock) { re.insert(); } cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::log::DummyLogger dl("dummy", "dummyLogger"); cta::log::LogContext lc(dl); cta::objectstore::AgentReference agr("UnitTests", dl); @@ -304,7 +304,7 @@ TEST(ObjectStore, RetrieveQueueToReportToRepackForSuccessRootEntryTest) { using cta::common::dataStructures::JobQueueType; cta::objectstore::BackendVFS be; cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::log::DummyLogger dl("dummy", "dummyLogger"); cta::log::LogContext lc(dl); cta::objectstore::AgentReference agr("UnitTests", dl); diff --git a/objectstore/SorterTest.cpp b/objectstore/SorterTest.cpp index cdb726bb47981f8afb3a73a6dc7f483e4c6e25fd..632501402873566d9688d3bb757a246141b1e455 100644 --- a/objectstore/SorterTest.cpp +++ b/objectstore/SorterTest.cpp @@ -54,7 +54,7 @@ TEST(ObjectStore,SorterInsertArchiveRequest){ re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -203,7 +203,7 @@ TEST(ObjectStore,SorterInsertRetrieveRequest){ re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -409,7 +409,7 @@ TEST(ObjectStore,SorterInsertDifferentTypesOfRequests){ re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -712,7 +712,7 @@ TEST(ObjectStore,SorterInsertArchiveRequestNotFetched){ re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); @@ -855,7 +855,7 @@ TEST(ObjectStore,SorterInsertRetrieveRequestNotFetched){ re.insert(); // Create the agent register cta::objectstore::EntryLogSerDeser el("user0", - "unittesthost", time(NULL)); + "unittesthost", time(nullptr)); cta::objectstore::ScopedExclusiveLock rel(re); // Create the agent for objects creation cta::objectstore::AgentReference agentRef("unitTestCreateEnv", dl); diff --git a/objectstore/cta-objectstore-initialize.cpp b/objectstore/cta-objectstore-initialize.cpp index e1af0c9a8831fcb71efcf1b38468891952b7bca4..6e556a0f776dd214b6a2074ffcfcd7aec9a80df8 100644 --- a/objectstore/cta-objectstore-initialize.cpp +++ b/objectstore/cta-objectstore-initialize.cpp @@ -57,7 +57,7 @@ int main(int argc, char ** argv) { cta::objectstore::AgentReference agr("cta-objectstore-initialize", logger); cta::objectstore::Agent ag(agr.getAgentAddress(), *be); ag.initialize(); - cta::objectstore::EntryLogSerDeser el("user0", "systemhost", time(NULL)); + cta::objectstore::EntryLogSerDeser el("user0", "systemhost", time(nullptr)); re.addOrGetAgentRegisterPointerAndCommit(agr,el, lc); rel.release(); ag.insertAndRegisterSelf(lc); diff --git a/rdbms/wrapper/SqliteRset.cpp b/rdbms/wrapper/SqliteRset.cpp index f9d51163f2b58d0a2af068707ec236d86c049d9f..d39d4fe2b7d02c9bdcdb0e455ec87bcec16af4dc 100644 --- a/rdbms/wrapper/SqliteRset.cpp +++ b/rdbms/wrapper/SqliteRset.cpp @@ -221,7 +221,7 @@ std::string SqliteRset::columnBlob(const std::string &colName) const { return std::string(); } else { const char *const colValue = reinterpret_cast<const char*>(sqlite3_column_blob(m_stmt.get(), idxAndType.colIdx)); - if(NULL == colValue) { + if(nullptr == colValue) { return std::string(); } int blobsize = sqlite3_column_bytes(m_stmt.get(), idxAndType.colIdx); @@ -242,7 +242,7 @@ std::optional<std::string> SqliteRset::columnOptionalString(const std::string &c return std::nullopt; } else { const char *const colValue = (const char *)sqlite3_column_text(m_stmt.get(), idxAndType.colIdx); - if(NULL == colValue) { + if(nullptr == colValue) { exception::Exception ex; ex.getMessage() << __FUNCTION__ << " failed: sqlite3_column_text() returned NULL when" " m_colNameToIdxAndType map states otherwise: colName=" << colName << ",colIdx=" << idxAndType.colIdx; diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 061ad038db011d99af16e3ecd7db1c896f7bfcd6..79b65d489c916f679c435c47855739851cc2fe0a 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -3327,7 +3327,7 @@ OStoreDB::TapeMountDecisionInfo::~TapeMountDecisionInfo() { // and then destroy the object if (m_lockTaken) m_lockOnSchedulerGlobalLock.release(); - m_schedulerGlobalLock.reset(NULL); + m_schedulerGlobalLock.reset(nullptr); } //------------------------------------------------------------------------------ diff --git a/scheduler/OStoreDB/OStoreDBFactory.hpp b/scheduler/OStoreDB/OStoreDBFactory.hpp index ed80da4a1f3541e9ac568f18d317ab8fe9869ea9..f6e20076199dd96afed396c784eda7f47e003ec4 100644 --- a/scheduler/OStoreDB/OStoreDBFactory.hpp +++ b/scheduler/OStoreDB/OStoreDBFactory.hpp @@ -82,7 +82,7 @@ public: re.fetch(); objectstore::Agent agent(m_agentReferencePtr->getAgentAddress(), *m_backend); agent.initialize(); - objectstore::EntryLogSerDeser cl("user0", "systemhost", time(NULL)); + objectstore::EntryLogSerDeser cl("user0", "systemhost", time(nullptr)); log::LogContext lc(*m_logger); re.addOrGetAgentRegisterPointerAndCommit(*m_agentReferencePtr, cl, lc); rel.release(); @@ -298,7 +298,7 @@ m_OStoreDB(*m_backend, *m_catalogue, *m_logger), re.fetch(); objectstore::Agent agent(m_agentReferencePtr->getAgentAddress(), *m_backend); agent.initialize(); - objectstore::EntryLogSerDeser cl("user0", "systemhost", time(NULL)); + objectstore::EntryLogSerDeser cl("user0", "systemhost", time(nullptr)); log::LogContext lc(*m_logger); re.addOrGetAgentRegisterPointerAndCommit(*m_agentReferencePtr, cl, lc); rel.release(); diff --git a/scheduler/OStoreDB/OStoreDBTest.cpp b/scheduler/OStoreDB/OStoreDBTest.cpp index d1fce2155065d1e3a3c6b423a9cf4482d18902e9..acc24c6cabd35221805a2c284b8615fb2d6eb508 100644 --- a/scheduler/OStoreDB/OStoreDBTest.cpp +++ b/scheduler/OStoreDB/OStoreDBTest.cpp @@ -84,7 +84,7 @@ class OStoreDBTest: public cta::objectstore::OStoreDBWrapperInterface &getDb() { cta::objectstore::OStoreDBWrapperInterface *const ptr = m_db.get(); - if (NULL == ptr) { + if (nullptr == ptr) { throw FailedToGetDatabase(); } return *ptr; diff --git a/scheduler/RetrieveMount.cpp b/scheduler/RetrieveMount.cpp index aa62be23087d8cb5c0b2dc713701735810d7d187..38a86ff08478133e46fd194bc2da44e922e25d8c 100644 --- a/scheduler/RetrieveMount.cpp +++ b/scheduler/RetrieveMount.cpp @@ -76,7 +76,7 @@ std::optional<std::string> cta::RetrieveMount::getActivity() const { std::string cta::RetrieveMount::getMountTransactionId() const{ std::stringstream id; if (!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getMountTransactionId(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getMountTransactionId(): got nullptr dbMount"); id << m_dbMount->mountInfo.mountId; return id.str(); } @@ -87,7 +87,7 @@ std::string cta::RetrieveMount::getMountTransactionId() const{ std::string cta::RetrieveMount::getPoolName() const{ std::stringstream sTapePool; if (!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getPoolName(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getPoolName(): got nullptr dbMount"); sTapePool << m_dbMount->mountInfo.tapePool; return sTapePool.str(); } @@ -99,7 +99,7 @@ std::string cta::RetrieveMount::getVo() const { std::stringstream sVo; if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getVo(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getVo(): got nullptr dbMount"); sVo<<m_dbMount->mountInfo.vo; return sVo.str(); } @@ -111,7 +111,7 @@ std::string cta::RetrieveMount::getMediaType() const { std::stringstream sMediaType; if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getMediaType(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getMediaType(): got nullptr dbMount"); sMediaType<<m_dbMount->mountInfo.mediaType; return sMediaType.str(); } @@ -123,7 +123,7 @@ std::string cta::RetrieveMount::getVendor() const { std::stringstream sVendor; if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getVendor(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getVendor(): got nullptr dbMount"); sVendor<<m_dbMount->mountInfo.vendor; return sVendor.str(); } @@ -135,7 +135,7 @@ std::string cta::RetrieveMount::getDrive() const { std::stringstream sDrive; if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getDrive(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getDrive(): got nullptr dbMount"); sDrive<<m_dbMount->mountInfo.drive; return sDrive.str(); } @@ -146,7 +146,7 @@ std::string cta::RetrieveMount::getDrive() const //------------------------------------------------------------------------------ uint64_t cta::RetrieveMount::getCapacityInBytes() const { if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getCapacityInBytes(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getCapacityInBytes(): got nullptr dbMount"); return m_dbMount->mountInfo.capacityInBytes; } @@ -155,7 +155,7 @@ uint64_t cta::RetrieveMount::getCapacityInBytes() const { //------------------------------------------------------------------------------ cta::common::dataStructures::Label::Format cta::RetrieveMount::getLabelFormat() const { if(!m_dbMount.get()) - throw exception::Exception("In cta::RetrieveMount::getLabelFormat(): got NULL dbMount"); + throw exception::Exception("In cta::RetrieveMount::getLabelFormat(): got nullptr dbMount"); return m_dbMount->mountInfo.labelFormat; } diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index cebafd6df9a0da3c5605170d0d96ab4bdbb5595c..7ffd30c229a3503594a3f2a28b27e28d86e9d447 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -194,7 +194,7 @@ std::string Scheduler::queueRetrieve( common::dataStructures::RetrieveFileQueueCriteria queueCriteria; queueCriteria = m_catalogue.prepareToRetrieveFile(instanceName, request.archiveFileID, request.requester, request.activity, lc, request.mountPolicy); - + queueCriteria.archiveFile.diskFileInfo = request.diskFileInfo; // The following block of code is a temporary fix for the following CTA issue: @@ -203,7 +203,7 @@ std::string Scheduler::queueRetrieve( // // The code tries to force a recall to use the tape copy with the // tape copy number equal to the number of days since the epoch. - // It reduces the number of overall number tape mounts + // It reduces the number of overall number tape mounts // in situations where files with multiple tape copies are being recalled. { @@ -213,14 +213,14 @@ std::string Scheduler::queueRetrieve( std::vector<uint64_t> tapeFileCopyNbs; - std::transform(queueCriteria.archiveFile.tapeFiles.begin(), queueCriteria.archiveFile.tapeFiles.end(),std::back_inserter(tapeFileCopyNbs), + std::transform(queueCriteria.archiveFile.tapeFiles.begin(), queueCriteria.archiveFile.tapeFiles.end(),std::back_inserter(tapeFileCopyNbs), [](const common::dataStructures::TapeFile &a) -> uint64_t { return a.copyNb;}); std::sort(tapeFileCopyNbs.begin(), tapeFileCopyNbs.end(), [](const uint64_t &a, const uint64_t &b) -> bool {return a > b;}); - + const uint64_t chosenCopyNb = tapeFileCopyNbs.at(indexToChose); const common::dataStructures::TapeFile chosenTapeFile = queueCriteria.archiveFile.tapeFiles.at(chosenCopyNb); @@ -1536,7 +1536,7 @@ auto logicalLibrary = getLogicalLibrary(logicalLibraryName,getLogicalLibrariesTi t.mediaType, t.vendor, t.capacityInBytes, - time(NULL), + time(nullptr), std::nullopt, t.labelFormat).release()); mountCreationTime += timer.secs(utils::Timer::resetCounter); @@ -1607,7 +1607,7 @@ auto logicalLibrary = getLogicalLibrary(logicalLibraryName,getLogicalLibrariesTi m->mediaType, m->vendor, m->capacityInBytes, - time(NULL), + time(nullptr), m->activity, m->labelFormat).release()); mountCreationTime += timer.secs(utils::Timer::resetCounter); @@ -1783,7 +1783,7 @@ std::list<common::dataStructures::QueueAndMountSummary> Scheduler::getQueuesAndM } if (pm.highestPriorityMountPolicyName) { summary.highestPriorityMountPolicy = pm.highestPriorityMountPolicyName.value(); - } + } if (pm.lowestRequestAgeMountPolicyName) { summary.lowestRequestAgeMountPolicy = pm.lowestRequestAgeMountPolicyName.value(); } @@ -1801,7 +1801,7 @@ std::list<common::dataStructures::QueueAndMountSummary> Scheduler::getQueuesAndM } if (pm.highestPriorityMountPolicyName) { summary.highestPriorityMountPolicy = pm.highestPriorityMountPolicyName.value(); - } + } if (pm.lowestRequestAgeMountPolicyName) { summary.lowestRequestAgeMountPolicy = pm.lowestRequestAgeMountPolicyName.value(); } diff --git a/scheduler/SchedulerDatabaseTest.cpp b/scheduler/SchedulerDatabaseTest.cpp index 57496c8a60d6f2c10f1e4c334ea8553b4a7fae15..3242c8a0f54dd6a5e973f316b4aa5be4ad3c9de0 100644 --- a/scheduler/SchedulerDatabaseTest.cpp +++ b/scheduler/SchedulerDatabaseTest.cpp @@ -84,7 +84,7 @@ public: cta::SchedulerDatabase &getDb() { cta::SchedulerDatabase *const ptr = m_db.get(); - if(NULL == ptr) { + if(nullptr == ptr) { throw FailedToGetDatabase(); } return *ptr; diff --git a/statistics/StatisticsSaveCmdLineArgs.cpp b/statistics/StatisticsSaveCmdLineArgs.cpp index 33b31591ea77669022cf366ce0033660294ada0c..27d741e1a03dcfeaf462fd82b6ba38913c192653 100644 --- a/statistics/StatisticsSaveCmdLineArgs.cpp +++ b/statistics/StatisticsSaveCmdLineArgs.cpp @@ -31,9 +31,9 @@ namespace statistics { StatisticsSaveCmdLineArgs::StatisticsSaveCmdLineArgs(const int argc, char *const *const argv): help(false) { static struct option longopts[] = { - {"catalogueconf", required_argument, NULL, 'c'}, - {"help", no_argument, NULL, 'h'}, - {NULL , 0, NULL, 0} + {"catalogueconf", required_argument, nullptr, 'c'}, + {"help", no_argument, nullptr, 'h'}, + {nullptr , 0, nullptr, 0} }; // Prevent getopt() from printing an error message if it does not recognize @@ -41,7 +41,7 @@ StatisticsSaveCmdLineArgs::StatisticsSaveCmdLineArgs(const int argc, char *const opterr = 0; int opt = 0; - while ((opt = getopt_long(argc, argv, ":hc:j", longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, ":hc:j", longopts, nullptr)) != -1) { switch (opt) { case 'h': help = true; diff --git a/statistics/StatisticsUpdateCmdLineArgs.cpp b/statistics/StatisticsUpdateCmdLineArgs.cpp index 32f6e0d934fa66215e492a8e82c10497cd27c352..d22e8474a132633e52d6958c03c26dff37c18c2d 100644 --- a/statistics/StatisticsUpdateCmdLineArgs.cpp +++ b/statistics/StatisticsUpdateCmdLineArgs.cpp @@ -32,8 +32,8 @@ namespace statistics { StatisticsUpdateCmdLineArgs::StatisticsUpdateCmdLineArgs(const int argc, char *const *const argv): help(false) { static struct option longopts[] = { - {"help", no_argument, NULL, 'h'}, - {NULL , 0, NULL, 0} + {"help", no_argument, nullptr, 'h'}, + {nullptr , 0, nullptr, 0} }; // Prevent getopt() from printing an error message if it does not recognize @@ -41,7 +41,7 @@ StatisticsUpdateCmdLineArgs::StatisticsUpdateCmdLineArgs(const int argc, char *c opterr = 0; int opt = 0; - while ((opt = getopt_long(argc, argv, ":h", longopts, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, ":h", longopts, nullptr)) != -1) { switch (opt) { case 'h': help = true; diff --git a/tapeserver/castor/messages/Frame.hpp b/tapeserver/castor/messages/Frame.hpp index db8dea32b267a8b8512620f575663fa97eed233a..331a05146a1a464b1fd6ff11778c82ecd0baaadd 100644 --- a/tapeserver/castor/messages/Frame.hpp +++ b/tapeserver/castor/messages/Frame.hpp @@ -68,7 +68,7 @@ private: * Calculates the hash value of the frame body and records the result in the * frame header. */ - void calcAndSetHashValueOfBody(); + void calcAndSetHashValueOfBody(); }; // struct Frame /** @@ -76,16 +76,16 @@ private: * * @param t The object. * @return The demangled type name. - */ + */ template <class T>std::string demangledNameOf(const T&t){ std::string responseType = typeid(t).name(); int status = -1; - char * demangled = abi::__cxa_demangle(responseType.c_str(), NULL, NULL, &status); + char * demangled = abi::__cxa_demangle(responseType.c_str(), nullptr, nullptr, &status); if (!status) { - responseType = demangled; + responseType = demangled; } free(demangled); - + return responseType; } diff --git a/tapeserver/castor/messages/messages.cpp b/tapeserver/castor/messages/messages.cpp index 942c0ddba076e43d4d5c4a007bce2cc5ac05f60c..6574878ef26efab446ed4411d471a5e664cc19a0 100644 --- a/tapeserver/castor/messages/messages.cpp +++ b/tapeserver/castor/messages/messages.cpp @@ -68,11 +68,11 @@ std::string castor::messages::computeSHA1Base64(void const* const data, EVP_DigestFinal_ex(&ctx, md_value, &md_len); // cleanup context EVP_MD_CTX_cleanup(&ctx); - - // base64 encode + + // base64 encode BIO *b64 = BIO_new(BIO_f_base64()); BIO *bmem = BIO_new(BIO_s_mem()); - if (NULL == b64 || NULL == bmem) { + if (nullptr == b64 || nullptr == bmem) { throw cta::exception::Exception("cant set up the environnement for computing the SHA1 in base64"); } b64 = BIO_push(b64, bmem); @@ -84,6 +84,6 @@ std::string castor::messages::computeSHA1Base64(void const* const data, std::string ret(bptr->data,bptr->length); BIO_free(bmem); BIO_free(b64); - + return ret; } diff --git a/tapeserver/castor/tape/doc/tape_howto.txt b/tapeserver/castor/tape/doc/tape_howto.txt index 6ad05a7a0601633376595457acb368ecddafcf67..97dc4832f851b178d1e9f270e29d9108c2c3dba5 100644 --- a/tapeserver/castor/tape/doc/tape_howto.txt +++ b/tapeserver/castor/tape/doc/tape_howto.txt @@ -4,7 +4,7 @@ Development servers VDQM servers: lxb8294 (dedicated PC) lxcastordev04 (virtual PC) - + Disk servers: lxc2disk07 lxc2disk08 @@ -17,7 +17,7 @@ Past tape servers (do not use): tpsrv250 (ibmlib3) tpsrv222 (ibmlib3) tpsrv233 (ibmlib1) - tpsrv234 (ibmlib1) + tpsrv234 (ibmlib1) Tape pools: vdqm2_test @@ -469,7 +469,7 @@ please confirm [yes]: [INFO] please wait... [INFO] commit OK <cdbop@cdbserv.cern.ch: ~> - + [root@lxb1366 root]# ccm-fetch [root@lxb1366 root]# ncm-ncd --co castorconf @@ -528,7 +528,7 @@ Start all daemons /etc/init.d/stagerd start for cname in `nslistclass | grep NAME | awk '{print $2}'` ; do enterFileClass --Name $cname --GetFromCns ; done -enterSvcClass --Name default --DiskPools default +enterSvcClass --Name default --DiskPools default enterSvcClass --Name dev --DiskPools extra enterSvcClass --Name diskonly --DiskPools extra --DiskOnlyBehavior yes --ForcedFileClass temp moveDiskServer default lxc2disk07.cern.ch @@ -705,8 +705,8 @@ How to mount, unload and then dismount a tape ============================================= [root@lxc2dev4d2 ~]# smc -h localhost -q D - 0 1 free - 1 2 free + 0 1 free + 1 2 free [root@lxc2dev4d2 ~]# smc -h localhost -q V V42001 1024 slot V42002 1025 slot @@ -716,7 +716,7 @@ V42005 1028 slot [root@lxc2dev4d2 ~]# smc -m -D 0 -h localhost -V V42001 [root@lxc2dev4d2 ~]# smc -h localhost -q D 0 1 loaded V42001 - 1 2 free + 1 2 free [root@lxc2dev4d2 ~]# smc -h localhost -q V V42001 1 drive V42002 1025 slot @@ -725,15 +725,15 @@ V42004 1027 slot V42005 1028 slot [root@lxc2dev4d2 ~]# smc -d -D 0 -h localhost -V V42001 [root@lxc2dev4d2 ~]# smc -h localhost -q D - 0 1 free - 1 2 free + 0 1 free + 1 2 free [root@lxc2dev4d2 ~]# smc -h localhost -q V V42001 1024 slot V42002 1025 slot V42003 1026 slot V42004 1027 slot V42005 1028 slot -[root@lxc2dev4d2 ~]# +[root@lxc2dev4d2 ~]# How to set the read priority of tape for a single-mount ======================================================= @@ -2546,7 +2546,7 @@ media letter and media cost: ******************************************************************************* T10000 T 200 [root@lxcastordev04 tape]# - + The model can now be entered into the tape-development setup: [root@lxcastordev04 tape]# vmgrentermodel --mo T10000 --ml T --mc 200 @@ -2809,11 +2809,11 @@ SQL> How to display the checksum extended file system attribute of a disk file ========================================================================= -[root@lxfsre4304 59]# getfattr -d 399131859@castorns.1010785562 -# file: 399131859@castorns.1010785562 -user.castor.checksum.type="ADLER32" -user.castor.checksum.value="99653f32" -[root@lxfsre4304 59]# +[root@lxfsre4304 59]# getfattr -d 399131859@castorns.1010785562 +# file: 399131859@castorns.1010785562 +user.castor.checksum.type="ADLER32" +user.castor.checksum.value="99653f32" +[root@lxfsre4304 59]# How to find the VDQM production server @@ -2997,7 +2997,7 @@ cdbop console: prod/services/castor/service/castoritdc.tpl profiles/profile_c2itdcsrv102.tpl [INFO] '/prod/services/castor/service/castoritdc': scheduled to be updated [INFO] '/profiles/profile_c2itdcsrv102': scheduled to be updated -<cdbop@cdbserv.cern.ch: ~/cdbop> +<cdbop@cdbserv.cern.ch: ~/cdbop> Commit the changes and quit. For example enter the following in the cdbop console: @@ -3051,7 +3051,7 @@ status: 0-1 => not picked by the mighunter 2 => attached to a stream 7 => the mighunter is analyzing them -3 => detached from the stream and sent to the aggregator +3 => detached from the stream and sent to the aggregator How to see the status of the streams in the stager database @@ -3307,7 +3307,7 @@ SQL> Run the following PL/SQL block modified to use your table as opposed to the one of this example. This script deletes the out-of-date tape copies and their associated segments. It fails the associated recall disk-copies and -restarts the associated recall sub-requests. +restarts the associated recall sub-requests. BEGIN @@ -3377,12 +3377,12 @@ VDQM HOST <VDQMhost> # /etc/init.d/vdqmd start 5) Chose te tapeserver(s) to be used by the new VDQM -# ssh tpstvABC +# ssh tpstvABC 6) Put DOWN the drive # tpmaint stop -7) Modify the VDQM HOST and add VDQM host to ADMIN HOSTS in the castor.conf +7) Modify the VDQM HOST and add VDQM host to ADMIN HOSTS in the castor.conf # vi /etc/castor/castor.conf ... ADMIN HOSTS <VDQMhost> ... @@ -3398,7 +3398,7 @@ VDQM HOST <VDQMhost> # /etc/init.d/rsyslog restart 9) Chek that it worked -[root@tpsrvABC ~]# showqueues +[root@tpsrvABC ~]# showqueues 35921005@tpsrvABC (0 MB) FREE vid: last update May 26 17:24:14 @@ -3828,11 +3828,11 @@ will fail with error messages of the form: In file included from /opt/globus/include/gcc64dbgpthr/globus_common.h:58, from /opt/globus/include/gcc64dbgpthr/gssapi.h:44, - from + from /opt/globus/include/gcc64dbgpthr/globus_gss_assist.h:38, - from + from /var/CASTOR_SVN_CO/trunk/security/Csec_plugin_GSS.c:51: -/opt/globus/include/gcc64dbgpthr/globus_common_include.h:19:27: error: +/opt/globus/include/gcc64dbgpthr/globus_common_include.h:19:27: error: globus_config.h: No such file or directory Run the follwing as root in order to fix the installation of the globus rpms: @@ -3901,7 +3901,7 @@ Comment: Adding plotutils package in order to get the pic2plot command-line prog [murrayc3@lxadm06 ~]$ exit logout Connection to lxadm closed. -[root@lxcastordev04 ~]# spma_wrapper.sh +[root@lxcastordev04 ~]# spma_wrapper.sh [INFO] NCM-NCD version 1.2.22 started by root at: Mon Oct 18 11:37:18 2010 [INFO] executing configure on components.... @@ -3924,7 +3924,7 @@ Connection to lxadm closed. [INFO] reading target configuration .. [INFO] executing operations.. [INFO] The following package operations are required: - install http://swrep/swrep/x86_64_slc5/ plotutils 2.5 5.el5 x86_64 + install http://swrep/swrep/x86_64_slc5/ plotutils 2.5 5.el5 x86_64 [INFO] Please be patient... 1 operation(s) to verify/execute. [OK] SPMA finished successfully. @@ -3941,7 +3941,7 @@ Connection to lxadm closed. ========================================================= [OK] 0 errors, 0 warnings executing configure -[root@lxcastordev04 ~]# +[root@lxcastordev04 ~]# How do I find the source files of the CASTOR web-site? @@ -3963,9 +3963,9 @@ How to find the locks existing in the DB? -- This relies on sql_prev_id, which might or might not point to the sql that took the lock select unique s.sid, s.program, s.process, l.type, l.id1, l.id2, l.ctime, l.block, do.object_name, sq.SQL_TEXT from v$session s - inner join v$lock l on l.sid = s.sid + inner join v$lock l on l.sid = s.sid left outer join v$sql sq on sq.sql_id = s.prev_sql_id - left outer join dba_objects do on do.object_id = l.id1 + left outer join dba_objects do on do.object_id = l.id1 where s.SCHEMANAME = 'STAGER_DEV03' order by OBJECT_NAME; @@ -3976,7 +3976,7 @@ How to find the blocked - blocker relationships in the DB? -- Find blocker, blocked and what they do or did. -- This relies on sql_prev_id, which might or might not point to the sql that took the lock select s.sid, s.process, s.program, s_sql.sql_text, blocker.sid "blocker sid", b_sql.sql_text "blocker prev sql" - from v$session s + from v$session s left outer join v$sql s_sql on s_sql.sql_id = s.sql_id left outer join v$session blocker on blocker.sid = s.blocking_session left outer join v$sql b_sql on b_sql.sql_id = blocker.prev_sql_id @@ -3986,10 +3986,10 @@ How to move to subversion 1.5.7 on a dev box ============================================ In template prod/cluster/castordev/customization/headnode/dev03.tpl, add: - + "/software/packages" = pkg_repl("subversion", "1.5.7-1", ELFMS_ARCH); "/software/packages" = pkg_add("neon", DEF, ELFMS_ARCH, "multi"); -"/software/packages" = pkg_add("neon", "0.27.2-1", ELFMS_ARCH, "multi"); +"/software/packages" = pkg_add("neon", "0.27.2-1", ELFMS_ARCH, "multi"); (neon is a dependancy). diff --git a/tests/ImmutableFileTestCmdLineArgs.cpp b/tests/ImmutableFileTestCmdLineArgs.cpp index 1afca9c058e6816cae7633021b2a716e8f055102..478c67fa0c0152c78eb0c3fd1a567c990bdb7439 100644 --- a/tests/ImmutableFileTestCmdLineArgs.cpp +++ b/tests/ImmutableFileTestCmdLineArgs.cpp @@ -30,8 +30,8 @@ ImmutableFileTestCmdLineArgs::ImmutableFileTestCmdLineArgs(const int argc, char help(false) { static struct option longopts[] = { - {"help", no_argument, NULL, 'h'}, - {NULL , 0, NULL, 0} + {"help", no_argument, nullptr, 'h'}, + {nullptr , 0, nullptr, 0} }; // Prevent getopt() from printing an error message if it does not recognize @@ -39,7 +39,7 @@ ImmutableFileTestCmdLineArgs::ImmutableFileTestCmdLineArgs(const int argc, char opterr = 0; int opt = 0; - while((opt = getopt_long(argc, argv, ":h", longopts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, ":h", longopts, nullptr)) != -1) { switch(opt) { case 'h': help = true; diff --git a/xroot_plugins/GrpcEndpoint.cpp b/xroot_plugins/GrpcEndpoint.cpp index 714edacab742bb4528b11665aa58a2861f8d4155..25f3ea1fa9ec88dd2f0ee03ec1d306d04af5a340 100644 --- a/xroot_plugins/GrpcEndpoint.cpp +++ b/xroot_plugins/GrpcEndpoint.cpp @@ -25,7 +25,7 @@ std::string cta::grpc::Endpoint::getPath(const std::string &diskFileId) const { // diskFileId is sent to CTA as a uint64_t, but we store it as a decimal string, cf.: // XrdSsiCtaRequestMessage.cpp: request.diskFileID = std::to_string(notification.file().fid()); // Here we convert it back to make the namespace query: - uint64_t id = strtoull(diskFileId.c_str(), NULL, 0); + uint64_t id = strtoull(diskFileId.c_str(), nullptr, 0); if(id == 0) return ("Invalid disk ID"); auto response = m_grpcClient->GetMD(eos::rpc::FILE, id, ""); @@ -36,7 +36,7 @@ std::string cta::grpc::Endpoint::getPathExceptionThrowing(const std::string &dis // diskFileId is sent to CTA as a uint64_t, but we store it as a decimal string, cf.: // XrdSsiCtaRequestMessage.cpp: request.diskFileID = std::to_string(notification.file().fid()); // Here we convert it back to make the namespace query: - uint64_t id = strtoull(diskFileId.c_str(), NULL, 0); + uint64_t id = strtoull(diskFileId.c_str(), nullptr, 0); if(id == 0) throw cta::exception::UserError("Invalid disk ID"); auto response = m_grpcClient->GetMD(eos::rpc::FILE, id, ""); diff --git a/xroot_plugins/XrdSsiCtaServiceProvider.hpp b/xroot_plugins/XrdSsiCtaServiceProvider.hpp index 9e38319f34f27131ef71ecbbff5fcda6e9497aec..3316d47ae3862af457c8fc9d261bb3a7392d869a 100644 --- a/xroot_plugins/XrdSsiCtaServiceProvider.hpp +++ b/xroot_plugins/XrdSsiCtaServiceProvider.hpp @@ -67,7 +67,7 @@ public: * * @param[in] rName The resource name * @param[in] contact Used by client-initiated queries for a resource at a particular endpoint. - * It is set to NULL for server-initiated queries. + * It is set to nullptr for server-initiated queries. * * @retval XrdSsiProvider::notPresent The resource does not exist * @retval XrdSsiProvider::isPresent The resource exists @@ -75,7 +75,7 @@ public: * only in clustered environments where the resource may be * immediately available on some other node.) */ - XrdSsiProvider::rStat QueryResource(const char *rName, const char *contact = 0) override; + XrdSsiProvider::rStat QueryResource(const char *rName, const char *contact = nullptr) override; /*! * Get a reference to the Scheduler DB for this Service diff --git a/xrootd-ssi-protobuf-interface b/xrootd-ssi-protobuf-interface index 0860a02dd2c443f4c122999a855368a99dfe4c79..fb0e62d4cd0288adbbf8da3c47d5f2f4221d7262 160000 --- a/xrootd-ssi-protobuf-interface +++ b/xrootd-ssi-protobuf-interface @@ -1 +1 @@ -Subproject commit 0860a02dd2c443f4c122999a855368a99dfe4c79 +Subproject commit fb0e62d4cd0288adbbf8da3c47d5f2f4221d7262