From 8980565881fcc484bb506b3135223b6a42aefbf0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 10 Nov 2015 10:18:19 +0100 Subject: loplugin:nullptr (automatic rewrite) Change-Id: I9dfcec9488b2a25e32d3934766d6d4b208a8c2dc --- jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx | 4 +- jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx | 2 +- .../plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 18 ++-- jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx | 2 +- jvmfwk/plugins/sunmajor/pluginlib/util.cxx | 26 ++--- jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx | 2 +- jvmfwk/source/elements.cxx | 106 ++++++++++----------- jvmfwk/source/framework.cxx | 86 ++++++++--------- jvmfwk/source/fwkbase.cxx | 8 +- jvmfwk/source/libxmlutil.cxx | 12 +-- 10 files changed, 133 insertions(+), 133 deletions(-) (limited to 'jvmfwk') diff --git a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx index d4d67f6e58bb..f824e0cc82fc 100644 --- a/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx +++ b/jvmfwk/plugins/sunmajor/javaenvsetup/javaldx.cxx @@ -64,7 +64,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) return -1; } - JavaInfo * pInfo = NULL; + JavaInfo * pInfo = nullptr; errcode = jfw_getSelectedJRE( & pInfo); if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS) @@ -73,7 +73,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) return -1; } - if (pInfo == NULL) + if (pInfo == nullptr) { if (!findAndSelect(&pInfo)) return -1; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx index 9abc9787669b..9c431146c777 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx @@ -88,7 +88,7 @@ char const* const* GnuInfo::getRuntimePaths(int * size) char const* const* GnuInfo::getLibraryPaths(int* /*size*/) { - return NULL; + return nullptr; } bool GnuInfo::initialize(vector > props) diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 6cd5c19267ec..52d1a3c36660 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -147,8 +147,8 @@ OString getPluginJarPath( JavaInfo* createJavaInfo(const rtl::Reference & info) { JavaInfo* pInfo = static_cast(rtl_allocateMemory(sizeof(JavaInfo))); - if (pInfo == NULL) - return NULL; + if (pInfo == nullptr) + return nullptr; OUString sVendor = info->getVendor(); pInfo->sVendor = sVendor.pData; rtl_uString_acquire(sVendor.pData); @@ -317,15 +317,15 @@ javaPluginError jfw_plugin_getAllJavaInfos( //nLenlist contains the number of elements in arExcludeList. //If no exclude list is provided then nLenList must be 0 - OSL_ASSERT( ! (arExcludeList == NULL && nLenList > 0)); - if (arExcludeList == NULL && nLenList > 0) + OSL_ASSERT( ! (arExcludeList == nullptr && nLenList > 0)); + if (arExcludeList == nullptr && nLenList > 0) return JFW_PLUGIN_E_INVALID_ARG; OSL_ASSERT(!sVendor.isEmpty()); if (sVendor.isEmpty()) return JFW_PLUGIN_E_INVALID_ARG; - JavaInfo** arInfo = NULL; + JavaInfo** arInfo = nullptr; //Find all JREs vector > vecInfos = @@ -383,8 +383,8 @@ javaPluginError jfw_plugin_getJavaInfoByPath( //nLenlist contains the number of elements in arExcludeList. //If no exclude list is provided then nLenList must be 0 - OSL_ASSERT( ! (arExcludeList == NULL && nLenList > 0)); - if (arExcludeList == NULL && nLenList > 0) + OSL_ASSERT( ! (arExcludeList == nullptr && nLenList > 0)); + if (arExcludeList == nullptr && nLenList > 0) return JFW_PLUGIN_E_INVALID_ARG; OSL_ASSERT(!sVendor.isEmpty()); @@ -654,7 +654,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( // unless errorcode is volatile the following warning occurs on gcc: // warning: variable 'errorcode' might be clobbered by `longjmp' or `vfork' volatile javaPluginError errorcode = JFW_PLUGIN_E_NONE; - if ( pInfo == NULL || ppVm == NULL || ppEnv == NULL) + if ( pInfo == nullptr || ppVm == nullptr || ppEnv == nullptr) return JFW_PLUGIN_E_INVALID_ARG; //Check if the Vendor (pInfo->sVendor) is supported by this plugin if ( ! isVendorSupported(pInfo->sVendor)) @@ -827,7 +827,7 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( */ g_bInGetJavaVM = 1; jint err; - JavaVM * pJavaVM = 0; + JavaVM * pJavaVM = nullptr; memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort)); int jmpval= setjmp( jmp_jvm_abort ); /* If jmpval is not "0" then this point was reached by a longjmp in the diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx index 667440c86ac9..47874405b731 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx @@ -205,7 +205,7 @@ bool SunVersion::init(const char *szVersion) SunVersion::PreRelease SunVersion::getPreRelease(const char *szRelease) { - if (szRelease == NULL) + if (szRelease == nullptr) return Rel_NONE; if( ! strcmp(szRelease,"internal")) return Rel_INTERNAL; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx index 1423c49578e8..b9ec44367588 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx @@ -235,7 +235,7 @@ private: inline FileHandleGuard::~FileHandleGuard() { - if (m_rHandle != 0) + if (m_rHandle != nullptr) { if (osl_closeFile(m_rHandle) != osl_File_E_None) { @@ -471,9 +471,9 @@ bool getJavaProps(const OUString & exePath, cArgs = 4; } - oslProcess javaProcess= 0; - oslFileHandle fileOut= 0; - oslFileHandle fileErr= 0; + oslProcess javaProcess= nullptr; + oslFileHandle fileOut= nullptr; + oslFileHandle fileErr= nullptr; FileHandleReader stdoutReader(fileOut); rtl::Reference< AsynchReader > stderrReader(new AsynchReader(fileErr)); @@ -484,12 +484,12 @@ bool getJavaProps(const OUString & exePath, args, cArgs, //sal_uInt32 nArguments, osl_Process_HIDDEN, //oslProcessOption Options, - NULL, //oslSecurity Security, + nullptr, //oslSecurity Security, usStartDir.pData,//usStartDir.pData,//usWorkDir.pData, //rtl_uString *strWorkDir, - NULL, //rtl_uString *strEnvironment[], + nullptr, //rtl_uString *strEnvironment[], 0, // sal_uInt32 nEnvironmentVars, &javaProcess, //oslProcess *pProcess, - NULL,//oslFileHandle *pChildInputWrite, + nullptr,//oslFileHandle *pChildInputWrite, &fileOut,//oslFileHandle *pChildOutputRead, &fileErr);//oslFileHandle *pChildErrorRead); @@ -564,7 +564,7 @@ bool getJavaProps(const OUString & exePath, */ bool decodeOutput(const OString& s, OUString* out) { - OSL_ASSERT(out != 0); + OSL_ASSERT(out != nullptr); OUStringBuffer buff(512); sal_Int32 nIndex = 0; do @@ -761,7 +761,7 @@ void addJREInfoFromBinPath( //map: jre/bin/java.exe for ( sal_Int32 pos = 0; - gVendorMap[pos].sVendorName != NULL; ++pos ) + gVendorMap[pos].sVendorName != nullptr; ++pos ) { vector vecPaths; getJavaExePaths_func pFunc = gVendorMap[pos].getJavaFunc; @@ -910,7 +910,7 @@ rtl::Reference getJREInfoByPath( // If this path is invalid then there is no chance to find a JRE here if (sResolvedDir.isEmpty()) { - return 0; + return nullptr; } //check if the directory path is good, that is a JRE was already recognized. @@ -927,7 +927,7 @@ rtl::Reference getJREInfoByPath( } for ( sal_Int32 pos = 0; - gVendorMap[pos].sVendorName != NULL; ++pos ) + gVendorMap[pos].sVendorName != nullptr; ++pos ) { vector vecPaths; getJavaExePaths_func pFunc = gVendorMap[pos].getJavaFunc; @@ -1053,7 +1053,7 @@ rtl::Reference getJREInfoByPath( { //find the creator func for the respective vendor name for ( sal_Int32 c = 0; - gVendorMap[c].sVendorName != NULL; ++c ) + gVendorMap[c].sVendorName != nullptr; ++c ) { OUString sNameMap(gVendorMap[c].sVendorName, strlen(gVendorMap[c].sVendorName), RTL_TEXTENCODING_ASCII_US); @@ -1087,7 +1087,7 @@ Reference createInstance(createInstance_func pFunc, if (aBase.is()) { if (!aBase->initialize(properties)) - aBase = 0; + aBase = nullptr; } return aBase; } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx index 5709e79a8f7a..81ce015402c2 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx @@ -43,7 +43,7 @@ VendorSupportMapEntry gVendorMap[] ={ {x, & y::getJavaExePaths, & y::createInstance}, #define END_VENDOR_MAP() \ - {NULL, NULL, NULL} }; + {nullptr, nullptr, nullptr} }; /* Examines if the vendor supplied in parameter sVendor is part of the list of supported vendors. That is the arry of VendorSupportMapEntry diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 8096841f6e18..30cd00e80f75 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -48,7 +48,7 @@ OString getElement(OString const & docPath, //Prepare the xml document and context OSL_ASSERT(!docPath.isEmpty()); jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr())); - if (doc == NULL) + if (doc == nullptr) throw FrameworkException( JFW_E_ERROR, OString("[Java framework] Error in function getElement " @@ -91,11 +91,11 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) OString sExcMsg("[Java framework] Error in function createSettingsStructure " "(elements.cxx)."); xmlNode * root = xmlDocGetRootElement(document); - if (root == NULL) + if (root == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); bool bFound = false; xmlNode * cur = root->children; - while (cur != NULL) + while (cur != nullptr) { if (xmlStrcmp(cur->name, reinterpret_cast("enabled")) == 0) { @@ -118,8 +118,8 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) //("enabled"), reinterpret_cast("")); - if (nodeEn == NULL) + root, nullptr, reinterpret_cast("enabled"), reinterpret_cast("")); + if (nodeEn == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlSetNsProp(nodeEn, nsXsi, reinterpret_cast("nil"), reinterpret_cast("true")); //add a new line @@ -128,8 +128,8 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) // xmlNode * nodeUs = xmlNewTextChild( - root, NULL, reinterpret_cast("userClassPath"), reinterpret_cast("")); - if (nodeUs == NULL) + root, nullptr, reinterpret_cast("userClassPath"), reinterpret_cast("")); + if (nodeUs == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlSetNsProp(nodeUs, nsXsi, reinterpret_cast("nil"), reinterpret_cast("true")); //add a new line @@ -138,8 +138,8 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) // xmlNode * nodeVm = xmlNewTextChild( - root, NULL, reinterpret_cast("vmParameters"), reinterpret_cast("")); - if (nodeVm == NULL) + root, nullptr, reinterpret_cast("vmParameters"), reinterpret_cast("")); + if (nodeVm == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlSetNsProp(nodeVm, nsXsi, reinterpret_cast("nil"), reinterpret_cast("true")); //add a new line @@ -148,8 +148,8 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) // xmlNode * nodeJre = xmlNewTextChild( - root, NULL, reinterpret_cast("jreLocations"), reinterpret_cast("")); - if (nodeJre == NULL) + root, nullptr, reinterpret_cast("jreLocations"), reinterpret_cast("")); + if (nodeJre == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlSetNsProp(nodeJre, nsXsi, reinterpret_cast("nil"), reinterpret_cast("true")); //add a new line @@ -158,8 +158,8 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) // xmlNode * nodeJava = xmlNewTextChild( - root, NULL, reinterpret_cast("javaInfo"), reinterpret_cast("")); - if (nodeJava == NULL) + root, nullptr, reinterpret_cast("javaInfo"), reinterpret_cast("")); + if (nodeJava == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlSetNsProp(nodeJava, nsXsi, reinterpret_cast("nil"), reinterpret_cast("true")); //add a new line @@ -169,7 +169,7 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) -VersionInfo::VersionInfo(): arVersions(NULL) +VersionInfo::VersionInfo(): arVersions(nullptr) { } @@ -186,7 +186,7 @@ void VersionInfo::addExcludeVersion(const OUString& sVersion) rtl_uString** VersionInfo::getExcludeVersions() { osl::MutexGuard guard(FwkMutex::get()); - if (arVersions != NULL) + if (arVersions != nullptr) return arVersions; arVersions = new rtl_uString*[vecExcludeVersions.size()]; @@ -256,23 +256,23 @@ void NodeJava::load() OString sSettingsPath = getSettingsPath(); //There must not be a share settings file CXmlDocPtr docUser(xmlParseFile(sSettingsPath.getStr())); - if (docUser == NULL) + if (docUser == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlNode * cur = xmlDocGetRootElement(docUser); - if (cur == NULL || cur->children == NULL) + if (cur == nullptr || cur->children == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); CXmlCharPtr sNil; cur = cur->children; - while (cur != NULL) + while (cur != nullptr) { if (xmlStrcmp(cur->name, reinterpret_cast("enabled")) == 0) { //only overwrite share settings if xsi:nil="false" sNil = xmlGetNsProp( cur, reinterpret_cast("nil"), reinterpret_cast(NS_SCHEMA_INSTANCE)); - if (sNil == NULL) + if (sNil == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg);; if (xmlStrcmp(sNil, reinterpret_cast("false")) == 0) { @@ -288,7 +288,7 @@ void NodeJava::load() { sNil = xmlGetNsProp( cur, reinterpret_cast("nil"), reinterpret_cast(NS_SCHEMA_INSTANCE)); - if (sNil == NULL) + if (sNil == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); if (xmlStrcmp(sNil, reinterpret_cast("false")) == 0) { @@ -301,7 +301,7 @@ void NodeJava::load() { sNil = xmlGetNsProp( cur, reinterpret_cast("nil"), reinterpret_cast(NS_SCHEMA_INSTANCE)); - if (sNil == NULL) + if (sNil == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); if (xmlStrcmp(sNil, reinterpret_cast("false")) == 0) @@ -315,7 +315,7 @@ void NodeJava::load() { sNil = xmlGetNsProp( cur, reinterpret_cast("nil"), reinterpret_cast(NS_SCHEMA_INSTANCE)); - if (sNil == NULL) + if (sNil == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); if (xmlStrcmp(sNil, reinterpret_cast("false")) == 0) { @@ -324,7 +324,7 @@ void NodeJava::load() std::vector ()); xmlNode * pOpt = cur->children; - while (pOpt != NULL) + while (pOpt != nullptr) { if (xmlStrcmp(pOpt->name, reinterpret_cast("param")) == 0) { @@ -341,7 +341,7 @@ void NodeJava::load() { sNil = xmlGetNsProp( cur, reinterpret_cast("nil"), reinterpret_cast(NS_SCHEMA_INSTANCE)); - if (sNil == NULL) + if (sNil == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); if (xmlStrcmp(sNil, reinterpret_cast("false")) == 0) { @@ -350,7 +350,7 @@ void NodeJava::load() std::vector()); xmlNode * pLoc = cur->children; - while (pLoc != NULL) + while (pLoc != nullptr) { if (xmlStrcmp(pLoc->name, reinterpret_cast("location")) == 0) { @@ -435,7 +435,7 @@ void NodeJava::write() const //Read the user elements OString sSettingsPath = getSettingsPath(); docUser = xmlParseFile(sSettingsPath.getStr()); - if (docUser == NULL) + if (docUser == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); contextUser = xmlXPathNewContext(docUser); if (xmlXPathRegisterNs(contextUser, reinterpret_cast("jf"), @@ -516,7 +516,7 @@ void NodeJava::write() const //remove option elements xmlNode* cur = vmParameters->children; - while (cur != NULL) + while (cur != nullptr) { xmlNode* lastNode = cur; cur = cur->next; @@ -533,7 +533,7 @@ void NodeJava::write() const typedef std::vector::const_iterator cit; for (cit i = m_vmParameters->begin(); i != m_vmParameters->end(); ++i) { - xmlNewTextChild(vmParameters, NULL, reinterpret_cast("param"), + xmlNewTextChild(vmParameters, nullptr, reinterpret_cast("param"), CXmlCharPtr(*i)); //add a new line xmlNode * nodeCrLf = xmlNewText(reinterpret_cast("\n")); @@ -557,7 +557,7 @@ void NodeJava::write() const //remove option elements xmlNode* cur = jreLocationsNode->children; - while (cur != NULL) + while (cur != nullptr) { xmlNode* lastNode = cur; cur = cur->next; @@ -574,7 +574,7 @@ void NodeJava::write() const typedef std::vector::const_iterator cit; for (cit i = m_JRELocations->begin(); i != m_JRELocations->end(); ++i) { - xmlNewTextChild(jreLocationsNode, NULL, reinterpret_cast("location"), + xmlNewTextChild(jreLocationsNode, nullptr, reinterpret_cast("location"), CXmlCharPtr(*i)); //add a new line xmlNode * nodeCrLf = xmlNewText(reinterpret_cast("\n")); @@ -604,7 +604,7 @@ void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect) m_javaInfo->bAutoSelect = bAutoSelect; m_javaInfo->bNil = false; - if (pInfo != NULL) + if (pInfo != nullptr) { m_javaInfo->m_bEmptyNode = false; m_javaInfo->sVendor = pInfo->sVendor; @@ -628,12 +628,12 @@ void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect) void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size) { - OSL_ASSERT( !(arOptions == 0 && size != 0)); + OSL_ASSERT( !(arOptions == nullptr && size != 0)); if ( ! m_vmParameters) m_vmParameters = boost::optional >( std::vector()); m_vmParameters->clear(); - if (arOptions != NULL) + if (arOptions != nullptr) { for (int i = 0; i < size; i++) { @@ -718,24 +718,24 @@ bool NodeJava::createSettingsDocument() const //Create the root element and name spaces xmlNodePtr root = xmlNewDocNode( - doc, NULL, reinterpret_cast("java"), reinterpret_cast("\n")); + doc, nullptr, reinterpret_cast("java"), reinterpret_cast("\n")); - if (root == NULL) + if (root == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); - if (xmlNewNs(root, reinterpret_cast(NS_JAVA_FRAMEWORK),NULL) == NULL) + if (xmlNewNs(root, reinterpret_cast(NS_JAVA_FRAMEWORK),nullptr) == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); - if (xmlNewNs(root,reinterpret_cast(NS_SCHEMA_INSTANCE),reinterpret_cast("xsi")) == NULL) + if (xmlNewNs(root,reinterpret_cast(NS_SCHEMA_INSTANCE),reinterpret_cast("xsi")) == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); xmlDocSetRootElement(doc, root); //Create a comment xmlNodePtr com = xmlNewComment( reinterpret_cast("This is a generated file. Do not alter this file!")); - if (com == NULL) + if (com == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); - if (xmlAddPrevSibling(root, com) == NULL) + if (xmlAddPrevSibling(root, com) == nullptr) throw FrameworkException(JFW_E_ERROR, sExcMsg); const OString path = getSettingsPath(); @@ -761,7 +761,7 @@ void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo) "(elements.cxx)."); OSL_ASSERT(pJavaInfo && pDoc); - if (pJavaInfo->children == NULL) + if (pJavaInfo->children == nullptr) return; //Get the xsi:nil attribute; CXmlCharPtr sNil; @@ -795,7 +795,7 @@ void CNodeJavaInfo::loadFromNode(xmlDoc * pDoc, xmlNode * pJavaInfo) xmlNode * cur = pJavaInfo->children; - while (cur != NULL) + while (cur != nullptr) { if (xmlStrcmp(cur->name, reinterpret_cast("vendor")) == 0) { @@ -904,7 +904,7 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, //Delete the children of JavaInfo xmlNode* cur = pJavaInfoNode->children; - while (cur != NULL) + while (cur != nullptr) { xmlNode* lastNode = cur; cur = cur->next; @@ -922,21 +922,21 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, xmlAddChild(pJavaInfoNode, nodeCrLf); //Create the vendor element - xmlNewTextChild(pJavaInfoNode, NULL, reinterpret_cast("vendor"), + xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast("vendor"), CXmlCharPtr(sVendor)); //add a new line for better readability nodeCrLf = xmlNewText(reinterpret_cast("\n")); xmlAddChild(pJavaInfoNode, nodeCrLf); //Create the location element - xmlNewTextChild(pJavaInfoNode, NULL, reinterpret_cast("location"), + xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast("location"), CXmlCharPtr(sLocation)); //add a new line for better readability nodeCrLf = xmlNewText(reinterpret_cast("\n")); xmlAddChild(pJavaInfoNode, nodeCrLf); //Create the version element - xmlNewTextChild(pJavaInfoNode, NULL, reinterpret_cast("version"), + xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast("version"), CXmlCharPtr(sVersion)); //add a new line for better readability nodeCrLf = xmlNewText(reinterpret_cast("\n")); @@ -945,7 +945,7 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, //Create the features element OUString sFeatures = OUString::number( nFeatures, 16); - xmlNewTextChild(pJavaInfoNode, NULL, reinterpret_cast("features"), + xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast("features"), CXmlCharPtr(sFeatures)); //add a new line for better readability nodeCrLf = xmlNewText(reinterpret_cast("\n")); @@ -955,7 +955,7 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, //Create the requirements element OUString sRequirements = OUString::number( nRequirements, 16); - xmlNewTextChild(pJavaInfoNode, NULL, reinterpret_cast("requirements"), + xmlNewTextChild(pJavaInfoNode, nullptr, reinterpret_cast("requirements"), CXmlCharPtr(sRequirements)); //add a new line for better readability nodeCrLf = xmlNewText(reinterpret_cast("\n")); @@ -964,7 +964,7 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, //Create the features element rtl::ByteSequence data = encodeBase16(arVendorData); - xmlNode* dataNode = xmlNewChild(pJavaInfoNode, NULL, + xmlNode* dataNode = xmlNewChild(pJavaInfoNode, nullptr, reinterpret_cast("vendorData"), reinterpret_cast("")); xmlNodeSetContentLen(dataNode, @@ -977,10 +977,10 @@ void CNodeJavaInfo::writeToNode(xmlDoc* pDoc, JavaInfo * CNodeJavaInfo::makeJavaInfo() const { if (bNil || m_bEmptyNode) - return NULL; + return nullptr; JavaInfo * pInfo = static_cast(rtl_allocateMemory(sizeof(JavaInfo))); - if (pInfo == NULL) - return NULL; + if (pInfo == nullptr) + return nullptr; memset(pInfo, 0, sizeof(JavaInfo)); pInfo->sVendor = sVendor.pData; rtl_uString_acquire(pInfo->sVendor); @@ -1072,11 +1072,11 @@ void MergedSettings::getVmParametersArray( rtl_uString *** parParams, sal_Int32 * size) const { osl::MutexGuard guard(FwkMutex::get()); - OSL_ASSERT(parParams != NULL && size != NULL); + OSL_ASSERT(parParams != nullptr && size != nullptr); *parParams = static_cast( rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size())); - if (*parParams == NULL) + if (*parParams == nullptr) return; int j=0; diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 1bd033fe13e7..eb16743f33dc 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -37,7 +37,7 @@ namespace { static bool g_bEnabledSwitchedOn = false; -static JavaVM * g_pJavaVM = NULL; +static JavaVM * g_pJavaVM = nullptr; bool areEqualJavaInfo( JavaInfo const * pInfoA,JavaInfo const * pInfoB) @@ -54,7 +54,7 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi { osl::MutexGuard guard(jfw::FwkMutex::get()); javaFrameworkError errcode = JFW_E_NONE; - if (pparInfo == NULL || pSize == NULL) + if (pparInfo == nullptr || pSize == nullptr) return JFW_E_INVALID_ARG; jfw::VendorSettings aVendorSettings; @@ -85,7 +85,7 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi //get all installations of one vendor according to minVersion, //maxVersion and excludeVersions sal_Int32 cInfos = 0; - JavaInfo** arInfos = NULL; + JavaInfo** arInfos = nullptr; std::vector> infos; javaPluginError plerr = jfw_plugin_getAllJavaInfos( true, @@ -173,7 +173,7 @@ javaFrameworkError SAL_CALL jfw_findAllJREs(JavaInfo ***pparInfo, sal_Int32 *pSi sal_Int32 nSize = vecInfo.size() + vecInfoManual2.size(); *pparInfo = static_cast(rtl_allocateMemory( nSize * sizeof(JavaInfo*))); - if (*pparInfo == NULL) + if (*pparInfo == nullptr) return JFW_E_ERROR; typedef std::vector::iterator it; @@ -202,7 +202,7 @@ javaFrameworkError SAL_CALL jfw_startVM( JavaVM ** ppVM, JNIEnv ** ppEnv) { javaFrameworkError errcode = JFW_E_NONE; - if (cOptions > 0 && arOptions == NULL) + if (cOptions > 0 && arOptions == nullptr) return JFW_E_INVALID_ARG; try @@ -211,16 +211,16 @@ javaFrameworkError SAL_CALL jfw_startVM( //We keep this pointer so we can determine if a VM has already //been created. - if (g_pJavaVM != NULL) + if (g_pJavaVM != nullptr) return JFW_E_RUNNING_JVM; - if (ppVM == NULL) + if (ppVM == nullptr) return JFW_E_INVALID_ARG; std::vector vmParams; OString sUserClassPath; jfw::CJavaInfo aInfo; - if (pInfo == NULL) + if (pInfo == nullptr) { jfw::JFW_MODE mode = jfw::getMode(); if (mode == jfw::JFW_MODE_APPLICATION) @@ -230,7 +230,7 @@ javaFrameworkError SAL_CALL jfw_startVM( return JFW_E_JAVA_DISABLED; aInfo.attach(settings.createJavaInfo()); //check if a Java has ever been selected - if (aInfo == NULL) + if (aInfo == nullptr) return JFW_E_NO_SELECT; #ifdef WNT @@ -297,7 +297,7 @@ javaFrameworkError SAL_CALL jfw_startVM( OSL_ASSERT(false); pInfo = aInfo.pInfo; } - assert(pInfo != NULL); + assert(pInfo != nullptr); //get the function jfw_plugin_startJavaVirtualMachine jfw::VendorSettings aVendorSettings; @@ -313,12 +313,12 @@ javaFrameworkError SAL_CALL jfw_startVM( //The first argument is the classpath arOpt[0].optionString= const_cast(sUserClassPath.getStr()); - arOpt[0].extraInfo = NULL; + arOpt[0].extraInfo = nullptr; // Set a flag that this JVM has been created via the JNI Invocation API // (used, for example, by UNO remote bridges to share a common thread pool // factory among Java and native bridge implementations): arOpt[1].optionString = const_cast("-Dorg.openoffice.native="); - arOpt[1].extraInfo = 0; + arOpt[1].extraInfo = nullptr; //add the options set by options dialog int index = 2; @@ -326,7 +326,7 @@ javaFrameworkError SAL_CALL jfw_startVM( for (cit i = vmParams.begin(); i != vmParams.end(); ++i) { arOpt[index].optionString = const_cast(i->getStr()); - arOpt[index].extraInfo = 0; + arOpt[index].extraInfo = nullptr; index ++; } //add all options of the arOptions argument @@ -338,7 +338,7 @@ javaFrameworkError SAL_CALL jfw_startVM( } //start Java - JavaVM *pVm = NULL; + JavaVM *pVm = nullptr; SAL_INFO("jfw", "Starting Java"); javaPluginError plerr = jfw_plugin_startJavaVirtualMachine(pInfo, arOpt, index, & pVm, ppEnv); if (plerr == JFW_PLUGIN_E_VM_CREATION_FAILED) @@ -414,7 +414,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) // first inspect Java installation that the JAVA_HOME // environment variable points to (if it is set) - JavaInfo* pHomeInfo = NULL; + JavaInfo* pHomeInfo = nullptr; if (jfw_plugin_getJavaInfoFromJavaHome(versionInfos, &pHomeInfo, infos) == JFW_PLUGIN_E_NONE) { @@ -443,7 +443,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) while(it != vecJavaInfosFromPath.end() && !bInfoFound) { JavaInfo* pJInfo = *it; - if (pJInfo != NULL) + if (pJInfo != nullptr) { // if the current Java installation implements all required features: use it if ((pJInfo->nFeatures & nFeatureFlags) == nFeatureFlags) @@ -451,7 +451,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) aCurrentInfo = pJInfo; bInfoFound = true; } - else if (static_cast(aCurrentInfo) == NULL) + else if (static_cast(aCurrentInfo) == nullptr) { // current Java installation does not provide all features // but no Java installation has been detected before @@ -485,7 +485,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) //get all installations of one vendor according to minVersion, //maxVersion and excludeVersions sal_Int32 cInfos = 0; - JavaInfo** arInfos = NULL; + JavaInfo** arInfos = nullptr; javaPluginError plerr = jfw_plugin_getAllJavaInfos( false, vendor, @@ -537,7 +537,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) //All Java installations found by the current plug-in lib //do not provide the required features. Try the next plug-in } - if (static_cast(aCurrentInfo) == NULL) + if (static_cast(aCurrentInfo) == nullptr) {//The plug-ins did not find a suitable Java. Now try the paths which have been //added manually. //get the list of paths to jre locations which have been added manually @@ -603,7 +603,7 @@ javaFrameworkError SAL_CALL jfw_findAndSelectJRE(JavaInfo **pInfo) //remember that this JRE was selected in this process jfw::setJavaSelected(); - if (pInfo !=NULL) + if (pInfo !=nullptr) { //copy to out param *pInfo = aCurrentInfo.cloneJavaInfo(); @@ -629,7 +629,7 @@ sal_Bool SAL_CALL jfw_areEqualJavaInfo( { if (pInfoA == pInfoB) return sal_True; - if (pInfoA == NULL || pInfoB == NULL) + if (pInfoA == nullptr || pInfoB == nullptr) return sal_False; OUString sVendor(pInfoA->sVendor); OUString sLocation(pInfoA->sLocation); @@ -650,7 +650,7 @@ sal_Bool SAL_CALL jfw_areEqualJavaInfo( void SAL_CALL jfw_freeJavaInfo(JavaInfo *pInfo) { - if (pInfo == NULL) + if (pInfo == nullptr) return; rtl_uString_release(pInfo->sVendor); rtl_uString_release(pInfo->sLocation); @@ -665,7 +665,7 @@ javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo) try { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (ppInfo == NULL) + if (ppInfo == nullptr) return JFW_E_INVALID_ARG; if (jfw::getMode() == jfw::JFW_MODE_DIRECT) @@ -692,7 +692,7 @@ javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo) aInfo.attach(settings.createJavaInfo()); if (! aInfo) { - *ppInfo = NULL; + *ppInfo = nullptr; return JFW_E_NONE; } //If the javavendors.xml has changed, then the current selected @@ -716,9 +716,9 @@ javaFrameworkError SAL_CALL jfw_getSelectedJRE(JavaInfo **ppInfo) javaFrameworkError SAL_CALL jfw_isVMRunning(sal_Bool *bRunning) { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (bRunning == NULL) + if (bRunning == nullptr) return JFW_E_INVALID_ARG; - if (g_pJavaVM == NULL) + if (g_pJavaVM == nullptr) *bRunning = sal_False; else *bRunning = sal_True; @@ -732,7 +732,7 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath( try { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (pPath == NULL || ppInfo == NULL) + if (pPath == nullptr || ppInfo == nullptr) return JFW_E_INVALID_ARG; OUString ouPath(pPath); @@ -753,7 +753,7 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath( //ask the plugin if this is a JRE. //If so check if it meets the version requirements. //Only if it does return a JavaInfo - JavaInfo* pInfo = NULL; + JavaInfo* pInfo = nullptr; javaPluginError plerr = jfw_plugin_getJavaInfoByPath( ouPath, vendor, @@ -770,7 +770,7 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath( } else if(plerr == JFW_PLUGIN_E_FAILED_VERSION) {//found JRE but it has the wrong version - *ppInfo = NULL; + *ppInfo = nullptr; errcode = JFW_E_FAILED_VERSION; break; } @@ -780,7 +780,7 @@ javaFrameworkError SAL_CALL jfw_getJavaInfoByPath( } OSL_ASSERT(false); } - if (*ppInfo == NULL && errcode != JFW_E_FAILED_VERSION) + if (*ppInfo == nullptr && errcode != JFW_E_FAILED_VERSION) errcode = JFW_E_NOT_RECOGNIZED; } catch (const jfw::FrameworkException& e) @@ -803,7 +803,7 @@ javaFrameworkError SAL_CALL jfw_setSelectedJRE(JavaInfo const *pInfo) if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; //check if pInfo is the selected JRE - JavaInfo *currentInfo = NULL; + JavaInfo *currentInfo = nullptr; errcode = jfw_getSelectedJRE( & currentInfo); if (errcode != JFW_E_NONE && errcode != JFW_E_INVALID_SETTINGS) return errcode; @@ -869,7 +869,7 @@ javaFrameworkError SAL_CALL jfw_getEnabled(sal_Bool *pbEnabled) if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; osl::MutexGuard guard(jfw::FwkMutex::get()); - if (pbEnabled == NULL) + if (pbEnabled == nullptr) return JFW_E_INVALID_ARG; jfw::MergedSettings settings; *pbEnabled = settings.getEnabled(); @@ -894,7 +894,7 @@ javaFrameworkError SAL_CALL jfw_setVMParameters( if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; jfw::NodeJava node(jfw::NodeJava::USER); - if (arOptions == NULL && nLen != 0) + if (arOptions == nullptr && nLen != 0) return JFW_E_INVALID_ARG; node.setVmParameters(arOptions, nLen); node.write(); @@ -919,7 +919,7 @@ javaFrameworkError SAL_CALL jfw_getVMParameters( if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; - if (parOptions == NULL || pLen == NULL) + if (parOptions == nullptr || pLen == nullptr) return JFW_E_INVALID_ARG; const jfw::MergedSettings settings; settings.getVmParametersArray(parOptions, pLen); @@ -942,7 +942,7 @@ javaFrameworkError SAL_CALL jfw_setUserClassPath(rtl_uString * pCp) if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; jfw::NodeJava node(jfw::NodeJava::USER); - if (pCp == NULL) + if (pCp == nullptr) return JFW_E_INVALID_ARG; node.setUserClassPath(pCp); node.write(); @@ -964,7 +964,7 @@ javaFrameworkError SAL_CALL jfw_getUserClassPath(rtl_uString ** ppCP) osl::MutexGuard guard(jfw::FwkMutex::get()); if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; - if (ppCP == NULL) + if (ppCP == nullptr) return JFW_E_INVALID_ARG; const jfw::MergedSettings settings; *ppCP = settings.getUserClassPath().pData; @@ -988,7 +988,7 @@ javaFrameworkError SAL_CALL jfw_addJRELocation(rtl_uString * sLocation) if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; jfw::NodeJava node(jfw::NodeJava::USER); - if (sLocation == NULL) + if (sLocation == nullptr) return JFW_E_INVALID_ARG; node.load(); node.addJRELocation(sLocation); @@ -1044,7 +1044,7 @@ void SAL_CALL jfw_unlock() namespace jfw { -CJavaInfo::CJavaInfo(): pInfo(0) +CJavaInfo::CJavaInfo(): pInfo(nullptr) { } @@ -1069,7 +1069,7 @@ void CJavaInfo::attach(::JavaInfo * info) ::JavaInfo * CJavaInfo::detach() { JavaInfo * tmp = pInfo; - pInfo = NULL; + pInfo = nullptr; return tmp; } @@ -1081,8 +1081,8 @@ CJavaInfo::~CJavaInfo() JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo) { - if (pInfo == NULL) - return NULL; + if (pInfo == nullptr) + return nullptr; JavaInfo* newInfo = static_cast(rtl_allocateMemory(sizeof(JavaInfo))); if (newInfo) @@ -1099,8 +1099,8 @@ JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo) JavaInfo* CJavaInfo::cloneJavaInfo() const { - if (pInfo == NULL) - return NULL; + if (pInfo == nullptr) + return nullptr; return copyJavaInfo(pInfo); } diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx index ff178a18166a..b7d1d91cda2a 100644 --- a/jvmfwk/source/fwkbase.cxx +++ b/jvmfwk/source/fwkbase.cxx @@ -103,7 +103,7 @@ VendorSettings::VendorSettings(): if (!sSettingsPath.isEmpty()) { m_xmlDocVendorSettings = xmlParseFile(sSettingsPath.getStr()); - if (m_xmlDocVendorSettings == NULL) + if (m_xmlDocVendorSettings == nullptr) throw FrameworkException( JFW_E_ERROR, OString("[Java framework] Error while parsing file: ") @@ -179,7 +179,7 @@ VersionInfo VendorSettings::getVersionInformation(const OUString & sVendor) if (!xmlXPathNodeSetIsEmpty(xPathObjectVersions->nodesetval)) { xmlNode* cur = xPathObjectVersions->nodesetval->nodeTab[0]; - while (cur != NULL) + while (cur != nullptr) { if (cur->type == XML_ELEMENT_NODE ) { @@ -212,7 +212,7 @@ std::vector VendorSettings::getSupportedVendors() { //get the values of the vendor elements + name attribute xmlNode* cur = result->nodesetval->nodeTab[0]; - while (cur != NULL) + while (cur != nullptr) { //between vendor elements are also text elements if (cur->type == XML_ELEMENT_NODE) @@ -346,7 +346,7 @@ OUString BootParams::getJREHome() else if (bEnvJRE) { const char * pJRE = getenv("JAVA_HOME"); - if (pJRE == NULL) + if (pJRE == nullptr) { throw FrameworkException( JFW_E_CONFIGURATION, diff --git a/jvmfwk/source/libxmlutil.cxx b/jvmfwk/source/libxmlutil.cxx index 35177e002ddb..73b4de3b9bae 100644 --- a/jvmfwk/source/libxmlutil.cxx +++ b/jvmfwk/source/libxmlutil.cxx @@ -22,7 +22,7 @@ namespace jfw { -CXPathObjectPtr::CXPathObjectPtr():_object(NULL) +CXPathObjectPtr::CXPathObjectPtr():_object(nullptr) { } @@ -45,7 +45,7 @@ CXPathContextPtr::CXPathContextPtr(xmlXPathContextPtr aContext) { } -CXPathContextPtr::CXPathContextPtr():_object(NULL) +CXPathContextPtr::CXPathContextPtr():_object(nullptr) { } @@ -69,7 +69,7 @@ CXmlDocPtr::CXmlDocPtr(xmlDoc* aDoc) { } -CXmlDocPtr::CXmlDocPtr():_object(NULL) +CXmlDocPtr::CXmlDocPtr():_object(nullptr) { } @@ -95,12 +95,12 @@ CXmlCharPtr::CXmlCharPtr(xmlChar * aChar) } CXmlCharPtr::CXmlCharPtr(const OUString & s): - _object(NULL) + _object(nullptr) { OString o = OUStringToOString(s, RTL_TEXTENCODING_UTF8); _object = xmlCharStrdup(o.getStr()); } -CXmlCharPtr::CXmlCharPtr():_object(NULL) +CXmlCharPtr::CXmlCharPtr():_object(nullptr) { } @@ -122,7 +122,7 @@ CXmlCharPtr & CXmlCharPtr::operator = (xmlChar* pObj) CXmlCharPtr::operator OUString() { OUString ret; - if (_object != NULL) + if (_object != nullptr) { OString aOStr(reinterpret_cast(_object)); ret = OStringToOUString(aOStr, RTL_TEXTENCODING_UTF8); -- cgit