You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/04/10 10:51:06 UTC

[celix] 03/32: Eliminate false positive coverity warning (CID=313587).

This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/coverity_fix
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 59c866ed84abfac41e9adf1e84a88b5365759bf5
Author: PengZheng <ho...@gmail.com>
AuthorDate: Mon Apr 10 14:31:22 2023 +0800

    Eliminate false positive coverity warning (CID=313587).
---
 libs/framework/src/bundle.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c
index 9ba6b4b2..74b0255e 100644
--- a/libs/framework/src/bundle.c
+++ b/libs/framework/src/bundle.c
@@ -207,19 +207,17 @@ celix_status_t bundle_createModule(bundle_pt bundle, module_pt* moduleOut) {
 
 
     const char * symName = NULL;
-    status = module_getSymbolicName(module, &symName);
-    if (status == CELIX_SUCCESS) {
-        /*
-         * NOTE only allowing a single bundle with a symbolic name.
-         * OSGi spec allows same symbolic name and different versions, but this is risky with
-         * the behaviour of dlopen when opening shared libraries with the same SONAME.
-         */
-        bool alreadyInstalled = celix_framework_isBundleAlreadyInstalled(bundle->framework, symName);
-        if (alreadyInstalled) {
-            status = CELIX_BUNDLE_EXCEPTION;
-            fw_logCode(bundle->framework->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot create module, bundle with symbolic name '%s' already installed.", symName);
-            return status;
-        }
+    (void)module_getSymbolicName(module, &symName); // it always succeeds
+    /*
+     * NOTE only allowing a single bundle with a symbolic name.
+     * OSGi spec allows same symbolic name and different versions, but this is risky with
+     * the behaviour of dlopen when opening shared libraries with the same SONAME.
+     */
+    bool alreadyInstalled = celix_framework_isBundleAlreadyInstalled(bundle->framework, symName);
+    if (alreadyInstalled) {
+        status = CELIX_BUNDLE_EXCEPTION;
+        fw_logCode(bundle->framework->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot create module, bundle with symbolic name '%s' already installed.", symName);
+        return status;
     }
 
     *moduleOut = module;