From c4c585a29871b4d66a38a409589c5e72e9fbe391 Mon Sep 17 00:00:00 2001 From: Ted Pudlik Date: Sat, 14 Jan 2023 00:26:43 +0000 Subject: [PATCH] pw_rpc: Remove an edge UB case Not all branches assign call_id. Based on cl/501757539. Change-Id: Id0aa67656fb1d295a2c24d268a7ab87f127bd8eb Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126533 Pigweed-Auto-Submit: Ted Pudlik Reviewed-by: Wyatt Hepler Commit-Queue: Auto-Submit --- pw_rpc/raw/client_testing.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pw_rpc/raw/client_testing.cc b/pw_rpc/raw/client_testing.cc index fd838bdbb0..47a9ea9566 100644 --- a/pw_rpc/raw/client_testing.cc +++ b/pw_rpc/raw/client_testing.cc @@ -71,8 +71,13 @@ Status FakeServer::ProcessPacket(internal::pwpb::PacketType type, } auto packet_encoding_result = - internal::Packet( - type, channel_id_, service_id, method_id, *call_id, payload, status) + internal::Packet(type, + channel_id_, + service_id, + method_id, + call_id.value_or(internal::Packet::kUnassignedId), + payload, + status) .Encode(packet_buffer_); PW_CHECK_OK(packet_encoding_result.status()); return client_.ProcessPacket(*packet_encoding_result);