aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-31 18:24:53 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-05-31 19:02:56 +0200
commit50feaf0af101bbbf4f80a9d6c2ccd0f73c31fe96 (patch)
tree2d934380caea9255e8f4607cf6cd174318bbdb5d
parentbcd9efc10d60e5f83218378fdd0a3ee847fb9c75 (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 4002dde..db5ddb8 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