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:23 UTC
[celix] 20/32: Fix Coverity 211226 Dereference after null check.
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 985158168b82ffdb7b90219f6400dac57e60a95a
Author: PengZheng <ho...@gmail.com>
AuthorDate: Mon Apr 10 17:13:41 2023 +0800
Fix Coverity 211226 Dereference after null check.
---
libs/framework/src/bundle_context.c | 13 +++----------
libs/framework/src/framework.c | 7 +------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index 593cf502..d85e21cf 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -336,17 +336,10 @@ celix_status_t bundleContext_addFrameworkListener(bundle_context_pt context, fra
}
celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
- celix_status_t status = CELIX_SUCCESS;
-
- if (context != NULL && listener != NULL) {
- fw_removeFrameworkListener(context->framework, context->bundle, listener);
- } else {
- status = CELIX_ILLEGAL_ARGUMENT;
+ if (context == NULL || listener == NULL) {
+ return CELIX_ILLEGAL_ARGUMENT;
}
-
- framework_logIfError(context->framework->logger, status, NULL, "Failed to remove framework listener");
-
- return status;
+ return fw_removeFrameworkListener(context->framework, context->bundle, listener);
}
celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) {
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index d4f06f42..97f08459 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -993,8 +993,6 @@ celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle,
}
celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
- celix_status_t status = CELIX_SUCCESS;
-
unsigned int i;
fw_framework_listener_pt frameworkListener;
@@ -1010,10 +1008,7 @@ celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bund
}
}
celixThreadMutex_unlock(&framework->frameworkListenersLock);
-
- framework_logIfError(framework->logger, status, NULL, "Failed to remove framework listener");
-
- return status;
+ return CELIX_SUCCESS;
}
long framework_getNextBundleId(framework_pt framework) {