aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-31 18:24:53 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-06-29 19:38:23 +0200
commit4988337d1e331b3d52823ca3ee72a3a753b1a405 (patch)
tree5d52d6dcc79c424c5568d2e6d951994b59bf94f0
parent16e7fd08827082449a28952f911806704396e19a (diff)
Use macro to test request validity
Use macro to test request validity before reponding to an api call. This macro handles if request is a pointer or a structure (depending if dynamic api are used). Change-Id: I2cd6539e0fe0b6e0324e82fbeef62731d0323be9 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--ctl-lib/ctl-action.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c
index a13cdd6..3ba598b 100644
--- a/ctl-lib/ctl-action.c
+++ b/ctl-lib/ctl-action.c
@@ -80,11 +80,11 @@ int ActionExecOne(CtlSourceT *source, CtlActionT* action, json_object *queryJ) {
/* AFB Subcall will release the json_object doing the json_object_put() call */
int err = AFB_ServiceSync(action->api, action->exec.subcall.api, action->exec.subcall.verb, json_object_get(queryJ), &returnJ);
- if(err && source->request)
+ if(err && AFB_ReqIsValid(source->request))
AFB_ReqFailF(source->request, "subcall-fail", "ActionExecOne(AppFw) uid=%s api=%s verb=%s args=%s", source->uid, action->exec.subcall.api, action->exec.subcall.verb, json_object_get_string(action->argsJ));
- else if(err && ! source->request)
+ else if(err && ! AFB_ReqIsValid(source->request))
AFB_ApiError(action->api, "ActionExecOne(AppFw) uid=%s api=%s verb=%s args=%s", source->uid, action->exec.subcall.api, action->exec.subcall.verb, json_object_get_string(action->argsJ));
- else if(source->request) {
+ else if(AFB_ReqIsValid(source->request)) {
if(wrap_json_unpack(returnJ, "{s:o}", "response", &toReturnJ))
AFB_ApiError(action->api, "ActionExecOne(Can't unpack response) uid=%s api=%s verb=%s args=%s", source->uid, action->exec.subcall.api, action->exec.subcall.verb, json_object_get_string(action->argsJ));
else