celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [42/51] celix git commit: CELIX-341: fix possible dereferencing error
Date Mon, 25 Jan 2016 18:01:58 GMT
CELIX-341: fix possible dereferencing error


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/fa4ee3c2
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/fa4ee3c2
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/fa4ee3c2

Branch: refs/heads/feature/CELIX-335_deploy_refactoring
Commit: fa4ee3c2a89711f83a7b6671bf577c5945ae8684
Parents: 79235f0
Author: Bjoern Petri <bpetri@apache.org>
Authored: Wed Jan 20 18:25:04 2016 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Wed Jan 20 18:25:04 2016 +0100

----------------------------------------------------------------------
 shell/private/src/shell.c | 126 +++++++++++++++++++++--------------------
 1 file changed, 64 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/fa4ee3c2/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index fc673bd..c48c265 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -108,78 +108,80 @@ celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) {
 }
 
 celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr) {
-	celix_status_t status = CELIX_SUCCESS;
-	command_service_pt command_ptr = NULL;
-	char *name_str = NULL;
-
-	if (!shell_ptr && !reference_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getService(shell_ptr->bundle_context_ptr, reference_ptr, (void
**) &command_ptr);
-		if (!command_ptr) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
-		if (!name_str) {
+    celix_status_t status = CELIX_SUCCESS;
+    command_service_pt command_ptr = NULL;
+    char *name_str = NULL;
+
+    if (!shell_ptr || !reference_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = bundleContext_getService(shell_ptr->bundle_context_ptr, reference_ptr,
(void **) &command_ptr);
+        if (!command_ptr) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
+        if (!name_str) {
             logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Command service
must contain a 'command.name' property!");
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
 
-	if (status == CELIX_SUCCESS) {
-		hashMap_put(shell_ptr->command_name_map_ptr, name_str, command_ptr);
-		hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
-	}
+    if (status == CELIX_SUCCESS) {
+        hashMap_put(shell_ptr->command_name_map_ptr, name_str, command_ptr);
+        hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr);
+    }
 
-	if (status != CELIX_SUCCESS) {
-		shell_removeCommand(shell_ptr, reference_ptr);
+    if (status != CELIX_SUCCESS) {
+        shell_removeCommand(shell_ptr, reference_ptr);
         char err[32];
         celix_strerror(status, err, 32);
         logHelper_log(shell_ptr->logHelper, OSGI_LOGSERVICE_ERROR, "Could not add command,
got error %s\n", err);
-	}
+    }
 
-	return status;
+    return status;
 }
 
 celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt reference_ptr)
{
-	celix_status_t status = CELIX_SUCCESS;
-
-	command_service_pt command_ptr = NULL;
-	char *name_str = NULL;
-
-	if (!shell_ptr || !reference_ptr) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		command_ptr = hashMap_remove(shell_ptr->command_reference_map_ptr, reference_ptr);
-		if (!command_ptr) {
-			status = CELIX_ILLEGAL_ARGUMENT;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
-		if (!name_str) {
-			status = CELIX_BUNDLE_EXCEPTION;
-		}
-	}
-
-	if (status == CELIX_SUCCESS) {
-		hashMap_remove(shell_ptr->command_name_map_ptr, name_str);
-	}
-
-	celix_status_t sub_status = bundleContext_ungetService(shell_ptr->bundle_context_ptr,
reference_ptr, NULL);
-	if (sub_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
-		status = sub_status;
-	}
-
-	return status;
+    celix_status_t status = CELIX_SUCCESS;
+
+    command_service_pt command_ptr = NULL;
+    char *name_str = NULL;
+
+    if (!shell_ptr || !reference_ptr) {
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    if (status == CELIX_SUCCESS) {
+        command_ptr = hashMap_remove(shell_ptr->command_reference_map_ptr, reference_ptr);
+        if (!command_ptr) {
+            status = CELIX_ILLEGAL_ARGUMENT;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        status = serviceReference_getProperty(reference_ptr, "command.name", &name_str);
+        if (!name_str) {
+            status = CELIX_BUNDLE_EXCEPTION;
+        }
+    }
+
+    if (status == CELIX_SUCCESS) {
+        hashMap_remove(shell_ptr->command_name_map_ptr, name_str);
+    }
+
+    if (status == CELIX_SUCCESS) {
+        celix_status_t sub_status = bundleContext_ungetService(shell_ptr->bundle_context_ptr,
reference_ptr, NULL);
+        if (sub_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+            status = sub_status;
+        }
+    }
+
+    return status;
 }
 
 celix_status_t shell_getCommands(shell_pt shell_ptr, array_list_pt *commands_ptr) {


Mime
View raw message