chore(userspace/falco): apply suggestions from review

Co-authored-by: deepskyblue86 <angelopuglisi86@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
Leonardo Grasso 2020-11-27 13:52:28 +01:00 committed by poiana
parent 9d31164a71
commit c237ddc738
2 changed files with 9 additions and 9 deletions

View File

@ -53,9 +53,9 @@ falco_outputs::~falco_outputs()
if(m_initialized) if(m_initialized)
{ {
this->stop_worker(); this->stop_worker();
for(auto it = m_outputs.cbegin(); it != m_outputs.cend(); ++it) for(auto o : m_outputs)
{ {
delete *it; delete o;
} }
} }
} }
@ -308,22 +308,22 @@ void falco_outputs::worker()
// Block until a message becomes available. // Block until a message becomes available.
m_queue.pop(cmsg); m_queue.pop(cmsg);
for(auto it = m_outputs.cbegin(); it != m_outputs.cend(); ++it) for(const auto o : m_outputs)
{ {
wd.set_timeout(timeout, (*it)->get_name()); wd.set_timeout(timeout, o->get_name());
try try
{ {
switch(cmsg.type) switch(cmsg.type)
{ {
case ctrl_msg_type::CTRL_MSG_OUTPUT: case ctrl_msg_type::CTRL_MSG_OUTPUT:
(*it)->output(&cmsg); o->output(&cmsg);
break; break;
case ctrl_msg_type::CTRL_MSG_CLEANUP: case ctrl_msg_type::CTRL_MSG_CLEANUP:
case ctrl_msg_type::CTRL_MSG_STOP: case ctrl_msg_type::CTRL_MSG_STOP:
(*it)->cleanup(); o->cleanup();
break; break;
case ctrl_msg_type::CTRL_MSG_REOPEN: case ctrl_msg_type::CTRL_MSG_REOPEN:
(*it)->reopen(); o->reopen();
break; break;
default: default:
falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n"); falco_logger::log(LOG_DEBUG, "Outputs worker received an unknown message type\n");
@ -331,7 +331,7 @@ void falco_outputs::worker()
} }
catch(const exception &e) catch(const exception &e)
{ {
falco_logger::log(LOG_ERR, (*it)->get_name() + ": " + string(e.what()) + "\n"); falco_logger::log(LOG_ERR, o->get_name() + ": " + string(e.what()) + "\n");
} }
} }
wd.cancel_timeout(); wd.cancel_timeout();

View File

@ -70,7 +70,7 @@ public:
} }
// Return the output's name as per its configuration. // Return the output's name as per its configuration.
const std::string get_name() const std::string get_name() const
{ {
return m_oc.name; return m_oc.name;
} }