Skip to content

Commit ecfe103

Browse files
Lambda setup
1 parent 18888b6 commit ecfe103

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

libs/bsw/uds/include/uds/DiagnosisConfiguration.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ class AbstractDiagnosisConfiguration
130130
{
131131
auto result = etl::find_if(
132132
IncomingDiagConnectionPool.begin(), IncomingDiagConnectionPool.end(), condition);
133+
134+
if (result == IncomingDiagConnectionPool.end()) {
135+
return nullptr;
136+
}
137+
133138
return reinterpret_cast<IncomingDiagConnection*>(result.operator->());
134139
}
135140

libs/bsw/uds/src/uds/connection/IncomingDiagConnection.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ IncomingDiagConnection::sendNegativeResponse(uint8_t const responseCode, Abstrac
263263
{
264264
++fNumPendingMessageProcessedCallbacks;
265265

266-
fSendNegativeResponseClosure = ::async::Function(
267-
[&, responseCode]() { asyncSendNegativeResponse(responseCode, &sender); });
266+
auto lambda =
267+
[&, responseCode]() { asyncSendNegativeResponse(responseCode, &sender); };
268+
fSendNegativeResponseClosure = ::async::Function(lambda);
268269
::async::execute(fContext, fSendNegativeResponseClosure);
269270
return ::uds::ErrorCode::OK;
270271
}
@@ -406,8 +407,8 @@ void IncomingDiagConnection::endNestedRequest()
406407
void IncomingDiagConnection::transportMessageProcessed(
407408
transport::TransportMessage& transportMessage, ProcessingResult const result)
408409
{
409-
fTransportMessageProcessedClosure = ::async::Function(
410-
[&, result]() { asyncTransportMessageProcessed(&transportMessage, result); });
410+
auto lambda = [&, result]() { asyncTransportMessageProcessed(&transportMessage, result); };
411+
fTransportMessageProcessedClosure = ::async::Function(lambda);
411412
::async::execute(fContext, fTransportMessageProcessedClosure);
412413
}
413414

libs/bsw/uds/test/gtest/src/uds/IntegrationTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ TEST_F(UdsIntegration, positive_response)
361361

362362
EXPECT_CALL(_messageProvider, releaseTransportMessage(SameAddress(pMessage)));
363363

364+
ASSERT_NE(pMessage, nullptr);
365+
364366
pProcessedListener->transportMessageProcessed(
365367
*pMessage,
366368
transport::ITransportMessageProcessedListener::ProcessingResult::PROCESSED_NO_ERROR);

0 commit comments

Comments
 (0)