diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-05-31 18:24:53 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-13 15:02:55 +0100 |
commit | 985d5cd5a5872ff8325bbbf5d4116298752ecd07 (patch) | |
tree | 2d934380caea9255e8f4607cf6cd174318bbdb5d /ctl-lib | |
parent | 17663dd0e59dd806187069dfe373998d4cd941ed (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>
Diffstat (limited to 'ctl-lib')
-rw-r--r-- | ctl-lib/ctl-action.c | 6 |
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 |