[Libreoffice-commits] core.git: include/jvmfwk jvmfwk/plugins jvmfwk/source

Stephan Bergmann sbergman at redhat.com
Tue Apr 11 17:11:13 UTC 2017


 include/jvmfwk/framework.hxx                        |   12 ------
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |    5 +-
 jvmfwk/source/elements.cxx                          |   10 ++++-
 jvmfwk/source/framework.cxx                         |   35 ++++++--------------
 4 files changed, 22 insertions(+), 40 deletions(-)

New commits:
commit 59fddf430f4d80c7e9ae0b7064697f5471bffedf
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Apr 11 19:10:23 2017 +0200

    Calls to jvmfwk/framework.hxx must not pass in null, drop JFW_E_INVALID_ARG
    
    Change-Id: Iff4b8ccc79e194f645791ac73818e3b677ae32a6

diff --git a/include/jvmfwk/framework.hxx b/include/jvmfwk/framework.hxx
index a3612a99e25a..fe806af5bc83 100644
--- a/include/jvmfwk/framework.hxx
+++ b/include/jvmfwk/framework.hxx
@@ -194,7 +194,6 @@ enum javaFrameworkError
 {
     JFW_E_NONE,
     JFW_E_ERROR,
-    JFW_E_INVALID_ARG,
     JFW_E_NO_SELECT,
     JFW_E_INVALID_SETTINGS,
     JFW_E_NEED_RESTART,
@@ -384,7 +383,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInf
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALID_ARG parInfo was NULL<br/>
     JFW_E_ERROR an error occurred. <br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.
@@ -413,7 +411,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_findAllJREs(
 
    @return
    JFW_E_NONE function ran successfully.<br/>
-   JFW_E_INVALID_ARG at least on of the parameters was NULL<br/>
    JFW_E_ERROR an error occurred. <br/>
    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
    were not met.</br>
@@ -468,8 +465,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getJavaInfoByPath(
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALID_ARG <code>ppVM</code>, <code>ppEnv</code> are NULL or
-    <code>arOptions</code> was NULL but <code>nSize</code> was greater 0.<br/>
     JFW_E_ERROR an error occurred. <br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.</br>
@@ -542,7 +537,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setSelectedJRE(JavaInfo const *pInfo);
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALIDARG <code>ppInfo</code> is a NULL.<br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
     JFW_E_INVALID_SETTINGS the javavendors.xml has been changed and no
@@ -576,7 +570,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setEnabled(bool bEnabled);
 
    @return
    JFW_E_NONE function ran successfully.<br/>
-   JFW_E_INVALIDARG pbEnabled is NULL<br/>
    JFW_E_ERROR An error occurred.<br/>
    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
@@ -600,7 +593,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getEnabled(bool *pbEnabled);
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALIDARG arArgs is NULL and nSize is not 0
     JFW_E_ERROR An error occurred.<br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
@@ -625,7 +617,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setVMParameters(
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALIDARG parParameters or pSize are  NULL<br/>
     JFW_E_ERROR An error occurred.<br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
@@ -647,7 +638,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getVMParameters(
 
    @return
    JFW_E_NONE function ran successfully.<br/>
-   JFW_E_INVALIDARG pCP is NULL.<br/>
    JFW_E_ERROR An error occurred.<br/>
    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
@@ -666,7 +656,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setUserClassPath(rtl_uString * pCP);
 
    @return
    JFW_E_NONE function ran successfully.<br/>
-   JFW_E_INVALIDARG ppCP is NULL.<br/>
    JFW_E_ERROR An error occurred.<br/>
    JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
@@ -694,7 +683,6 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getUserClassPath(rtl_uString ** ppCP);
 
     @return
     JFW_E_NONE function ran successfully.<br/>
-    JFW_E_INVALIDARG sLocation is NULL.<br/>
     JFW_E_ERROR An error occurred.<br/>
     JFW_E_CONFIGURATION mode was not properly set or their prerequisites
     were not met.<br/>
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();


More information about the Libreoffice-commits mailing list