diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-11 19:10:23 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-11 19:10:48 +0200 |
commit | 59fddf430f4d80c7e9ae0b7064697f5471bffedf (patch) | |
tree | 45a756bc4af8ee35486b246804f2c0d165e2070c /jvmfwk | |
parent | 8aa8be724dafc266d7daeae325806ca2caae2efe (diff) |
Calls to jvmfwk/framework.hxx must not pass in null, drop JFW_E_INVALID_ARG
Change-Id: Iff4b8ccc79e194f645791ac73818e3b677ae32a6
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 5 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 10 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 35 |
3 files changed, 22 insertions, 28 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index a5f11e6a3c21..84e60a9cf254 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -645,14 +645,15 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( JavaVM ** ppVm, JNIEnv ** ppEnv) { + assert(pInfo != nullptr); + assert(ppVm != nullptr); + assert(ppEnv != nullptr); // unless guard is volatile the following warning occurs on gcc: // warning: variable 't' might be clobbered by `longjmp' or `vfork' volatile osl::MutexGuard guard(PluginMutex::get()); // unless errorcode is volatile the following warning occurs on gcc: // warning: variable 'errorcode' might be clobbered by `longjmp' or `vfork' volatile javaPluginError errorcode = javaPluginError::NONE; - if ( pInfo == nullptr || ppVm == nullptr || ppEnv == nullptr) - return javaPluginError::InvalidArg; //Check if the Vendor (pInfo->sVendor) is supported by this plugin if ( ! isVendorSupported(pInfo->sVendor)) return javaPluginError::WrongVendor; diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index b5846f134cb4..64258699713e 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cassert> + #include "elements.hxx" #include "osl/mutex.hxx" #include "osl/file.hxx" @@ -626,7 +630,7 @@ void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect) void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size) { - OSL_ASSERT( !(arOptions == nullptr && size != 0)); + assert( !(arOptions == nullptr && size != 0)); if ( ! m_vmParameters) m_vmParameters = boost::optional<std::vector<OUString> >( std::vector<OUString>()); @@ -643,7 +647,7 @@ void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size) void NodeJava::addJRELocation(rtl_uString * sLocation) { - OSL_ASSERT( sLocation); + assert( sLocation); if (!m_JRELocations) m_JRELocations = boost::optional<std::vector<OUString> >( std::vector<OUString> ()); @@ -1062,8 +1066,8 @@ bool MergedSettings::getJavaInfoAttrAutoSelect() const void MergedSettings::getVmParametersArray( rtl_uString *** parParams, sal_Int32 * size) const { + assert(parParams != nullptr && size != nullptr); osl::MutexGuard guard(FwkMutex::get()); - OSL_ASSERT(parParams != nullptr && size != nullptr); *parParams = static_cast<rtl_uString **>( rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size())); diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 5bfa77695e83..9c3a35c56aca 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cassert> #include <memory> #include "rtl/ustring.hxx" #include "rtl/bootstrap.hxx" @@ -49,11 +52,10 @@ bool areEqualJavaInfo( javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparInfo) { + assert(pparInfo != nullptr); try { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (pparInfo == nullptr) - return JFW_E_INVALID_ARG; pparInfo->clear(); jfw::VendorSettings aVendorSettings; @@ -191,9 +193,9 @@ javaFrameworkError jfw_startVM( JavaInfo const * pInfo, JavaVMOption * arOptions, sal_Int32 cOptions, JavaVM ** ppVM, JNIEnv ** ppEnv) { + assert(cOptions == 0 || arOptions != nullptr); + assert(ppVM != nullptr); javaFrameworkError errcode = JFW_E_NONE; - if (cOptions > 0 && arOptions == nullptr) - return JFW_E_INVALID_ARG; try { @@ -204,9 +206,6 @@ javaFrameworkError jfw_startVM( if (g_pJavaVM != nullptr) return JFW_E_RUNNING_JVM; - if (ppVM == nullptr) - return JFW_E_INVALID_ARG; - std::vector<OString> vmParams; OString sUserClassPath; std::unique_ptr<JavaInfo> aInfo; @@ -634,12 +633,11 @@ bool jfw_areEqualJavaInfo(JavaInfo const * pInfoA,JavaInfo const * pInfoB) javaFrameworkError jfw_getSelectedJRE(std::unique_ptr<JavaInfo> *ppInfo) { + assert(ppInfo != nullptr); javaFrameworkError errcode = JFW_E_NONE; try { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (ppInfo == nullptr) - return JFW_E_INVALID_ARG; if (jfw::getMode() == jfw::JFW_MODE_DIRECT) { @@ -692,12 +690,12 @@ bool jfw_isVMRunning() javaFrameworkError jfw_getJavaInfoByPath(rtl_uString *pPath, std::unique_ptr<JavaInfo> *ppInfo) { + assert(pPath != nullptr); + assert(ppInfo != nullptr); javaFrameworkError errcode = JFW_E_NONE; try { osl::MutexGuard guard(jfw::FwkMutex::get()); - if (pPath == nullptr || ppInfo == nullptr) - return JFW_E_INVALID_ARG; OUString ouPath(pPath); @@ -825,14 +823,13 @@ javaFrameworkError jfw_setEnabled(bool bEnabled) javaFrameworkError jfw_getEnabled(bool *pbEnabled) { + assert(pbEnabled != nullptr); javaFrameworkError errcode = JFW_E_NONE; try { if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; osl::MutexGuard guard(jfw::FwkMutex::get()); - if (pbEnabled == nullptr) - return JFW_E_INVALID_ARG; jfw::MergedSettings settings; *pbEnabled = settings.getEnabled(); } @@ -856,8 +853,6 @@ javaFrameworkError jfw_setVMParameters( if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; jfw::NodeJava node(jfw::NodeJava::USER); - if (arOptions == nullptr && nLen != 0) - return JFW_E_INVALID_ARG; node.setVmParameters(arOptions, nLen); node.write(); } @@ -881,8 +876,6 @@ javaFrameworkError jfw_getVMParameters( if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; - if (parOptions == nullptr || pLen == nullptr) - return JFW_E_INVALID_ARG; const jfw::MergedSettings settings; settings.getVmParametersArray(parOptions, pLen); } @@ -897,6 +890,7 @@ javaFrameworkError jfw_getVMParameters( javaFrameworkError jfw_setUserClassPath(rtl_uString * pCp) { + assert(pCp != nullptr); javaFrameworkError errcode = JFW_E_NONE; try { @@ -904,8 +898,6 @@ javaFrameworkError 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 == nullptr) - return JFW_E_INVALID_ARG; node.setUserClassPath(pCp); node.write(); } @@ -920,14 +912,13 @@ javaFrameworkError jfw_setUserClassPath(rtl_uString * pCp) javaFrameworkError jfw_getUserClassPath(rtl_uString ** ppCP) { + assert(ppCP != nullptr); javaFrameworkError errcode = JFW_E_NONE; try { osl::MutexGuard guard(jfw::FwkMutex::get()); if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; - if (ppCP == nullptr) - return JFW_E_INVALID_ARG; const jfw::MergedSettings settings; *ppCP = settings.getUserClassPath().pData; rtl_uString_acquire(*ppCP); @@ -950,8 +941,6 @@ javaFrameworkError 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 == nullptr) - return JFW_E_INVALID_ARG; node.load(); node.addJRELocation(sLocation); node.write(); |