diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-04-18 16:25:24 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-05-24 16:28:53 +0200 |
commit | 9cb51ee3170262d8720d47708f483b4b38fd38e6 (patch) | |
tree | f4bf3940f3da01dd8e5f141becb97f96b074c33c /lib | |
parent | be68761ad6b10555ce410f1f0e42976014f7b259 (diff) |
Normalize coding style among repository
Normalize coding style among project :
- When possible, set the variable outside test in 'if' statement.
- Remove fanciful returns.
- Split too long lines.
- Remove unnecessary '\n' into prints.
- Normalize use of tabulation.
- Use 'afb_req_fail' instead of 'afb_req_fail_f' when possible.
- Add some error prints.
BUG-AGL: SPEC-2329
Change-Id: I14867e05e02b4c4c0389108c335fec2d2aa27495
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.c | 20 | ||||
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c | 24 |
2 files changed, 20 insertions, 24 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c index 314190f..26bbd23 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c @@ -96,16 +96,14 @@ int8_t HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList int64_t HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList) { - int8_t ret; int64_t mixerDataRemoved = 0; if(! mixerDataList) return -1; while(*mixerDataList) { - ret = HalUtlRemoveSelectedMixerData(mixerDataList, *mixerDataList); - if(ret) - return (int64_t) ret; + if(HalUtlRemoveSelectedMixerData(mixerDataList, *mixerDataList)) + return -2; mixerDataRemoved++; } @@ -134,11 +132,10 @@ struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHa { struct InternalHalMixerData *currentMixerData; - if(! mixerDataList || ! verb) + if(! mixerDataList || ! *mixerDataList || ! verb) return NULL; currentMixerData = *mixerDataList; - while(currentMixerData) { if((! strcmp(verb, currentMixerData->verb)) && (! strcmp(verbToCall, currentMixerData->verbToCall)) && @@ -152,7 +149,7 @@ struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHa } /******************************************************************************* - * Hal data handling functions * + * Hal data handling functions * ******************************************************************************/ struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList) @@ -233,16 +230,14 @@ int8_t HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalD int64_t HalUtlRemoveAllHalFromList(struct HalData **halDataList) { - int8_t ret; int64_t halRemoved = 0; if(! halDataList) return -1; while(*halDataList) { - ret = HalUtlRemoveSelectedHalFromList(halDataList, *halDataList); - if(ret) - return (int64_t) ret; + if(HalUtlRemoveSelectedHalFromList(halDataList, *halDataList)) + return -2; halRemoved++; } @@ -259,7 +254,6 @@ int64_t HalUtlGetNumberOfHalInList(struct HalData **halDataList) return -1; currentHalData = *halDataList; - while(currentHalData) { currentHalData = currentHalData->next; numberOfHal++; @@ -276,7 +270,6 @@ struct HalData *HalUtlSearchHalDataByApiName(struct HalData **halDataList, char return NULL; currentHalData = *halDataList; - while(currentHalData) { if(! strcmp(apiName, currentHalData->apiName)) return currentHalData; @@ -295,7 +288,6 @@ struct HalData *HalUtlSearchReadyHalDataByCardId(struct HalData **halDataList, i return NULL; currentHalData = *halDataList; - while(currentHalData) { if(currentHalData->status == HAL_STATUS_READY && currentHalData->sndCardId == cardId) return currentHalData; diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c index ed06b27..2960537 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c @@ -45,23 +45,26 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType) json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL; - if(! (apiHandle = afb_req_get_api(request))) { - afb_req_fail(request, "api_handle", "Can't get current hal controller api handle"); + apiHandle = afb_req_get_api(request); + if(! apiHandle) { + afb_req_fail(request, "api_handle", "Can't get current hal api handle"); return; } - if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) { - afb_req_fail(request, "hal_controller_config", "Can't get current hal controller config"); + ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle); + if(! ctrlConfig) { + afb_req_fail(request, "hal_controller_config", "Can't get current internal hal controller config"); return; } currentHalData = (struct HalData *) getExternalData(ctrlConfig); if(! currentHalData) { - afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data"); + afb_req_fail(request, "hal_controller_data", "Can't get current internal hal controller data"); return; } - if(! (requestJson = afb_req_json(request))) { + requestJson = afb_req_json(request); + if(! requestJson) { afb_req_fail(request, "request_json", "Can't get request json"); return; } @@ -261,14 +264,15 @@ struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t ap createdStreamData->verbToCall = strdup(verbToCall); createdStreamData->streamCardId = strdup(streamCardId); - if((! createdStreamData->verb) || - (! createdStreamData->verbToCall) || - (! createdStreamData->streamCardId)) { + if(! createdStreamData->verb || + ! createdStreamData->verbToCall || + ! createdStreamData->streamCardId) { HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } - if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) { + createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb); + if(! createdStreamData->event) { HalUtlRemoveSelectedMixerData(¤tHalData->internalHalData->streamsData, createdStreamData); return NULL; } |