diff options
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer-binding.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp index 0603656..09f1b30 100644 --- a/signal-composer-binding/signal-composer-binding.cpp +++ b/signal-composer-binding/signal-composer-binding.cpp @@ -236,10 +236,9 @@ void list(afb_req request) /// @brief entry point for get requests. void get(struct afb_req request) { - int err = 0, i = 0; - size_t l = 0; + int err = 0; struct json_object* args = afb_req_json(request), *ans = nullptr, - *options = nullptr, *error = nullptr, *object = nullptr; + *options = nullptr, *error = nullptr; const char* sig; // Process about Raw CAN message on CAN bus directly @@ -253,18 +252,11 @@ void get(struct afb_req request) ans = Composer::instance().getsignalValue(sig, options); - l = json_object_array_length(ans); - if(l) { - while(i < l) { - object = json_object_array_get_idx(ans, i++); - if(json_object_object_get_ex(object, "error", &error)) - break; - } - if(error) + if (json_object_array_length(ans)) + if(json_object_object_get_ex(ans, "error", &error)) afb_req_fail(request, "error", json_object_get_string(error)); else afb_req_success(request, ans, NULL); - } else afb_req_fail(request, "error", "No signals found."); |