summaryrefslogtreecommitdiffstats
path: root/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-20 19:46:11 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 15:55:03 +0100
commitfae627b646e9ab709adbd0c60d7582176375e0c3 (patch)
tree7f1a6bb834aeb6b191be2fd3c4b9715f7fa4fb5c /low-can-binding
parent04b7efcdd1a8dfdf461c78d083aabee5445e54bd (diff)
low-can-cb: improve readability
Just make thing more readable by define variables at the beginning of functions. And directly assign them if possible. Also improve format using the same format than in the rest of the project. Bug-AGL: SPEC-2932 Change-Id: I5cc7685b80734d0eb43a29fc06b2a8434f3469fa Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding')
-rw-r--r--low-can-binding/binding/low-can-cb.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/low-can-binding/binding/low-can-cb.cpp b/low-can-binding/binding/low-can-cb.cpp
index 3037994a..20ed39d4 100644
--- a/low-can-binding/binding/low-can-cb.cpp
+++ b/low-can-binding/binding/low-can-cb.cpp
@@ -53,21 +53,16 @@
int config_low_can(afb_api_t apiHandle, CtlSectionT *section, json_object *json_obj)
{
AFB_DEBUG("Config %s", json_object_to_json_string(json_obj));
- CtlConfigT *ctrlConfig;
-
- ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
- if(! ctrlConfig)
- return -1;
+ CtlConfigT *ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ int active_message_set = 0;
+ json_object *dev_mapping = nullptr;
+ const char *diagnotic_bus = nullptr;
- if(! ctrlConfig->external)
+ if(! ctrlConfig || ! ctrlConfig->external)
return -1;
application_t *application = (application_t*) ctrlConfig->external;
- int active_message_set;
- json_object *dev_mapping = nullptr;
- const char *diagnotic_bus = nullptr;
-
if(wrap_json_unpack(json_obj, "{si, ss}",
"active_message_set", &active_message_set,
"diagnostic_bus", &diagnotic_bus))
@@ -196,7 +191,7 @@ static int subscribe_unsubscribe_diagnostic_messages(afb_req_t request,
event_filter.frequency = event_filter.frequency == 0 ? sig->get_frequency() : event_filter.frequency;
std::shared_ptr<low_can_subscription_t> can_subscription;
- auto it = std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub)
+ auto it = std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub)
{
return (! sub.second->get_diagnostic_message().empty());
});