summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Desneux <stephane.desneux@iot.bzh>2019-10-17 13:41:13 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-10-17 13:41:13 +0000
commitbbb0d18bf36d19d3251c5dcff8953ddc98301d5f (patch)
tree0bc4a1c934d77f34948a03734e17fe1dddffcb0f
parent31095e8c09a57d35b693a3665ffc1c6aa1045cb9 (diff)
parent4063c990f8b146504bcc49b2fb1d1082f58bf707 (diff)
Merge "Move hal api delete code into a function"
-rw-r--r--src/4a-hal-manager/4a-hal-manager.c18
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.c38
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.h1
3 files changed, 46 insertions, 11 deletions
diff --git a/src/4a-hal-manager/4a-hal-manager.c b/src/4a-hal-manager/4a-hal-manager.c
index da33db8..c587e8a 100644
--- a/src/4a-hal-manager/4a-hal-manager.c
+++ b/src/4a-hal-manager/4a-hal-manager.c
@@ -78,30 +78,26 @@ static int HalMgrInitApi(afb_api_t apiHandle)
if(afb_api_require_api(apiHandle, currentHalData->apiName, 1) ||
currentHalData->status == HAL_STATUS_INIT_FAILED) {
- AFB_API_ERROR(apiHandle,
- "Error caught during '%s' api initialization, this api won't be reachable",
- currentHalData->apiName);
+ AFB_API_INFO(apiHandle,
+ "Error caught during '%s' api initialization, this api won't be reachable",
+ currentHalData->apiName);
toDeleteApiName = strdup(currentHalData->apiName);
if(! toDeleteApiName) {
AFB_API_ERROR(apiHandle, "Didn't succeed to store (allocate) 'apiName' string");
- return -5;
+ return -4;
}
- err = HalUtlRemoveHalDataAndDeleteHalApi(apiHandle, currentHalData, &halMgrData->halDataListHead);
+ err = InternalHalDeleteApi(apiHandle, &halMgrData->halDataListHead, currentHalData);
if(err) {
AFB_API_ERROR(apiHandle,
- "Error %i happened while trying to delete '%s' api and to remove all its data",
+ "Error %i happened when tried to delete %s api",
err,
toDeleteApiName);
free(toDeleteApiName);
- return -6;
+ return -5;
}
- AFB_API_ERROR(apiHandle,
- "Api '%s' and all its data has been deleted",
- toDeleteApiName);
-
free(toDeleteApiName);
}
}
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c
index 5334bdf..ba742f1 100644
--- a/src/4a-internals-hal/4a-internals-hal-api-loader.c
+++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c
@@ -199,6 +199,44 @@ int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *hal
return 0;
}
+int InternalHalDeleteApi(afb_api_t apiHandle, struct cds_list_head *halDataListHead, struct HalData *toDeleteHalData)
+{
+ int err;
+
+ char *toDeleteApiName;
+
+ if(! apiHandle || ! toDeleteHalData) {
+ AFB_API_ERROR(apiHandle, "Invalid argument(s)");
+ return -1;
+ }
+
+ toDeleteApiName = strdup(toDeleteHalData->apiName);
+ if(! toDeleteApiName) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to store (allocate) 'apiName' string");
+ return -2;
+ }
+
+ err = HalUtlRemoveHalDataAndDeleteHalApi(toDeleteHalData->internalHalData->apiHandle,
+ toDeleteHalData,
+ halDataListHead);
+ if(err) {
+ AFB_API_ERROR(apiHandle,
+ "Error %i happened while trying to delete '%s' api and to remove all its data",
+ err,
+ toDeleteApiName);
+ free(toDeleteApiName);
+ return -3;
+ }
+
+ AFB_API_NOTICE(apiHandle,
+ "Api '%s' and all its data has been deleted",
+ toDeleteApiName);
+
+ free(toDeleteApiName);
+
+ return 0;
+}
+
int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData)
{
int index;
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.h b/src/4a-internals-hal/4a-internals-hal-api-loader.h
index fa878e2..1628e8a 100644
--- a/src/4a-internals-hal/4a-internals-hal-api-loader.h
+++ b/src/4a-internals-hal/4a-internals-hal-api-loader.h
@@ -26,6 +26,7 @@
// Verbs that can be use to create api
int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *halMgrData);
+int InternalHalDeleteApi(afb_api_t apiHandle, struct cds_list_head *halDataListHead, struct HalData *toDeleteHalData);
int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData);
#endif /* _INTERNALS_HAL_API_LOADER_INCLUDE_ */ \ No newline at end of file