diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-12 19:51:38 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-03-16 17:10:41 +0100 |
commit | 95d91c64f891ece71fa196178345bacf9e3967d6 (patch) | |
tree | f23e3f297899b832835b687809481e84a205f9cb /src | |
parent | 7617950b0ab386949b43c6f221b02826e18548d6 (diff) |
Change method returned value. Needed with send_request()
method to retrieve the active_diagnostic_request.
Change-Id: Icfba704e40be211021dc81ec18fa3602d736afdb
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/diagnostic/diagnostic-manager.cpp | 14 | ||||
-rw-r--r-- | src/diagnostic/diagnostic-manager.hpp | 3 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp index 6e8a68c..6867ec3 100644 --- a/src/diagnostic/diagnostic-manager.cpp +++ b/src/diagnostic/diagnostic-manager.cpp @@ -138,21 +138,19 @@ void diagnostic_manager_t::cleanup_active_requests(bool force) /// @brief Note that this pops it off of whichver list it was on and returns it, so make /// sure to add it to some other list or it'll be lost. -bool diagnostic_manager_t::lookup_recurring_request(const DiagnosticRequest* request) +active_diagnostic_request_t* diagnostic_manager_t::find_recurring_request(const DiagnosticRequest* request) { - active_diagnostic_request_t existingEntry; for (auto& entry : recurring_requests_) { active_diagnostic_request_t* candidate = entry; - if(candidate->get_can_bus_dev()->get_device_name() == bus_->get_device_name() && - diagnostic_request_equals(&candidate->get_handle()->request, request)) + if(diagnostic_request_equals(&candidate->get_handle()->request, request)) { find_and_erase(entry, recurring_requests_); - return true; + return entry; break; } } - return false; + return nullptr; } std::shared_ptr<can_bus_dev_t> diagnostic_manager_t::get_can_bus_dev() @@ -225,7 +223,7 @@ bool diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, con cleanup_active_requests(false); bool added = true; - if(lookup_recurring_request(request)) + if(find_recurring_request(request) == nullptr) { active_diagnostic_request_t* entry = get_free_entry(); @@ -290,7 +288,7 @@ int diagnostic_manager_t::send_request(sd_event_source *s, uint64_t usec, void * { diagnostic_manager_t& dm = configuration_t::instance().get_diagnostic_manager(); DiagnosticRequest* request = (DiagnosticRequest*)userdata; - active_diagnostic_request_t* adr = dm.lookup_recurring_request(request); + active_diagnostic_request_t* adr = dm.find_recurring_request(request); if(adr != nullptr && adr->get_can_bus_dev() == dm.get_can_bus_dev() && adr->should_send() && dm.clear_to_send(adr)) diff --git a/src/diagnostic/diagnostic-manager.hpp b/src/diagnostic/diagnostic-manager.hpp index aa98c0b..29223fa 100644 --- a/src/diagnostic/diagnostic-manager.hpp +++ b/src/diagnostic/diagnostic-manager.hpp @@ -80,8 +80,7 @@ public: void cancel_request(active_diagnostic_request_t* entry); void cleanup_request(active_diagnostic_request_t* entry, bool force); void cleanup_active_requests(bool force); - bool lookup_recurring_request(const DiagnosticRequest* request); - + active_diagnostic_request_t* find_recurring_request(const DiagnosticRequest* request); bool validate_optional_request_attributes(float frequencyHz); |