Overflow detection, span-based signatures, flatten control flow

This commit is contained in:
Ian Gulliver
2026-04-10 23:02:07 +09:00
parent 8408603390
commit 76c519c17a
7 changed files with 67 additions and 56 deletions

View File

@@ -31,8 +31,13 @@ static ResponseTest test_discovery() {
uint8_t req_buf[1514];
span_writer req_out(req_buf, sizeof(req_buf));
size_t req_len = encode_request_into(req_out, 0, RequestInfo{});
auto send_result = w6300::send(test_socket, std::span<const uint8_t>{req_buf, req_len});
auto req_len = encode_response_into(req_out, 0, RequestInfo{});
if (!req_len) {
resp.pass = false;
resp.messages.push_back("encode: overflow");
return resp;
}
auto send_result = w6300::send(test_socket, std::span<const uint8_t>{req_buf, *req_len});
if (!send_result) {
resp.pass = false;
resp.messages.push_back("send: error " + std::to_string(static_cast<int>(send_result.error())));