From 4988337d1e331b3d52823ca3ee72a3a753b1a405 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Thu, 31 May 2018 18:24:53 +0200 Subject: 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 --- ctl-lib/ctl-action.c | 6 +++--- 1 file 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 -- cgit 1.2.3-korg