fix CI compilation error by replacing let_value stdexec::just() | stdexec::let_value(f) where f takes no arguments is semantically identical to calling f() directly, since just() sends no values and let_value simply forwards them to f. Replace the pattern with the direct call to avoid the let_value constexpr completion-signature computation path, which triggers a compile error in stdexec's __typeinfo.hpp due to pointer comparison of inline constexpr globals in a constant expression context. In sensor_manager.cpp an immediately-invoked lambda expression is used. In handler_test.cpp the lambda is stored in a named variable before invocation to preserve the closure lifetime across coroutine suspension points, matching the original behavior where let_value held the closure in its operation state. No behavior change. Change-Id: I3c6b6a432d3a5c594ea7a99b5c9e338898e3893a Signed-off-by: Vishnunithyasoundhar S <vishnunithyasoundhar.s@intel.com>
diff --git a/platform-mc/sensor_manager.cpp b/platform-mc/sensor_manager.cpp index 6a1994d..c408e92 100644 --- a/platform-mc/sensor_manager.cpp +++ b/platform-mc/sensor_manager.cpp
@@ -126,8 +126,7 @@ std::forward_as_tuple()) .first->second; scope.spawn( - stdexec::just() | stdexec::let_value([this, &rcOpt, - tid] -> exec::task<void> { + [this, &rcOpt, tid]() -> exec::task<void> { auto res = co_await stdexec::stopped_as_optional(doSensorPollingTask(tid)); if (res.has_value()) @@ -154,7 +153,7 @@ } rcOpt = PLDM_SUCCESS; } - }), + }(), exec::default_task_context<void>(stdexec::inline_scheduler{})); }
diff --git a/requester/test/handler_test.cpp b/requester/test/handler_test.cpp index 1a86e50..588c265 100644 --- a/requester/test/handler_test.cpp +++ b/requester/test/handler_test.cpp
@@ -184,33 +184,33 @@ auto instanceId = instanceIdResult.value(); EXPECT_EQ(instanceId, 0); - scope.spawn( - stdexec::just() | stdexec::let_value([&] -> exec::task<void> { - pldm::Request request(sizeof(pldm_msg_hdr) + sizeof(uint8_t), 0); - const pldm_msg* responseMsg = nullptr; - size_t responseLen = 0; - int rc = PLDM_SUCCESS; + auto coroFn = [&]() -> exec::task<void> { + pldm::Request request(sizeof(pldm_msg_hdr) + sizeof(uint8_t), 0); + const pldm_msg* responseMsg = nullptr; + size_t responseLen = 0; + int rc = PLDM_SUCCESS; - auto requestPtr = std::start_lifetime_as<pldm_msg>(request.data()); - requestPtr->hdr.instance_id = instanceId; + auto requestPtr = std::start_lifetime_as<pldm_msg>(request.data()); + requestPtr->hdr.instance_id = instanceId; - try - { - std::tie(rc, responseMsg, responseLen) = - co_await reqHandler.sendRecvMsg(eid, std::move(request)); - } - catch (...) - { - std::rethrow_exception(std::current_exception()); - } + try + { + std::tie(rc, responseMsg, responseLen) = + co_await reqHandler.sendRecvMsg(eid, std::move(request)); + } + catch (...) + { + std::rethrow_exception(std::current_exception()); + } - EXPECT_NE(responseLen, 0); + EXPECT_NE(responseLen, 0); - this->pldmResponseCallBack(eid, responseMsg, responseLen); + this->pldmResponseCallBack(eid, responseMsg, responseLen); - EXPECT_EQ(validResponse, true); - }), - exec::default_task_context<void>(stdexec::inline_scheduler{})); + EXPECT_EQ(validResponse, true); + }; + scope.spawn(coroFn(), + exec::default_task_context<void>(stdexec::inline_scheduler{})); pldm::Response mockResponse(sizeof(pldm_msg_hdr) + sizeof(uint8_t), 0); auto mockResponsePtr = @@ -234,19 +234,19 @@ bool stopped = false; - scope.spawn( - stdexec::just() | stdexec::let_value([&] -> exec::task<void> { - pldm::Request request(sizeof(pldm_msg_hdr) + sizeof(uint8_t), 0); - pldm::Response response; + auto coroFn = [&]() -> exec::task<void> { + pldm::Request request(sizeof(pldm_msg_hdr) + sizeof(uint8_t), 0); + pldm::Response response; - auto requestPtr = std::start_lifetime_as<pldm_msg>(request.data()); - requestPtr->hdr.instance_id = instanceId; + auto requestPtr = std::start_lifetime_as<pldm_msg>(request.data()); + requestPtr->hdr.instance_id = instanceId; - co_await reqHandler.sendRecvMsg(eid, std::move(request)); + co_await reqHandler.sendRecvMsg(eid, std::move(request)); - EXPECT_TRUE(false); // unreachable - }) | stdexec::upon_stopped([&] { stopped = true; }), - exec::default_task_context<void>(stdexec::inline_scheduler{})); + EXPECT_TRUE(false); // unreachable + }; + scope.spawn(coroFn() | stdexec::upon_stopped([&] { stopped = true; }), + exec::default_task_context<void>(stdexec::inline_scheduler{})); scope.request_stop(); @@ -293,16 +293,16 @@ uint8_t expectedTid = 1; + auto coroFn = [&]() -> exec::task<void> { + uint8_t respTid = 0; + + co_await _::getTIDTask(reqHandler, eid, instanceId, respTid); + + EXPECT_EQ(expectedTid, respTid); + }; // Execute a coroutine to send getTID command. The coroutine is suspended // until reqHandler.handleResponse() is received. - scope.spawn(stdexec::just() | stdexec::let_value([&] -> exec::task<void> { - uint8_t respTid = 0; - - co_await _::getTIDTask(reqHandler, eid, instanceId, - respTid); - - EXPECT_EQ(expectedTid, respTid); - }), + scope.spawn(coroFn(), exec::default_task_context<void>(stdexec::inline_scheduler{})); pldm::Response mockResponse(