From 95d91c64f891ece71fa196178345bacf9e3967d6 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sun, 12 Mar 2017 19:51:38 +0100 Subject: Change method returned value. Needed with send_request() method to retrieve the active_diagnostic_request. Change-Id: Icfba704e40be211021dc81ec18fa3602d736afdb Signed-off-by: Romain Forlot --- src/diagnostic/diagnostic-manager.cpp | 14 ++++++-------- 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 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); -- cgit 1.2.3-korg