[api] Default sent=-1 in write_raw_ for cleaner cold path call sites

This commit is contained in:
J. Nick Koston
2026-03-29 11:42:42 -10:00
parent 847c2ddbbf
commit 371070ab78
3 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ class APIFrameHelper {
}
// Slow path (out-of-line): handle partial writes, errors, overflow buffering
APIError write_raw_(const struct iovec *iov, int iovcnt, uint16_t total_write_len, ssize_t sent);
APIError write_raw_(const struct iovec *iov, int iovcnt, uint16_t total_write_len, ssize_t sent = -1);
// Socket ownership (4 bytes on 32-bit, 8 bytes on 64-bit)
std::unique_ptr<socket::Socket> socket_;
@@ -541,7 +541,7 @@ APIError APINoiseFrameHelper::write_frame_(const uint8_t *data, uint16_t len) {
if (len == 0) {
struct iovec iov = {header, 3};
return this->write_raw_(&iov, 1, 3, -1);
return this->write_raw_(&iov, 1, 3);
}
struct iovec iov[2];
iov[0].iov_base = header;
@@ -549,7 +549,7 @@ APIError APINoiseFrameHelper::write_frame_(const uint8_t *data, uint16_t len) {
iov[1].iov_base = const_cast<uint8_t *>(data);
iov[1].iov_len = len;
return this->write_raw_(iov, 2, 3 + len, -1);
return this->write_raw_(iov, 2, 3 + len);
}
/** Initiate the data structures for the handshake.
@@ -220,12 +220,12 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) {
char msg[INDICATOR_MSG_SIZE];
memcpy_P(msg, MSG_PROGMEM, INDICATOR_MSG_SIZE);
struct iovec iov = {msg, INDICATOR_MSG_SIZE};
this->write_raw_(&iov, 1, INDICATOR_MSG_SIZE, -1);
this->write_raw_(&iov, 1, INDICATOR_MSG_SIZE);
#else
static const char MSG[] = "\x00"
"Bad indicator byte";
struct iovec iov = {const_cast<char *>(MSG), INDICATOR_MSG_SIZE};
this->write_raw_(&iov, 1, INDICATOR_MSG_SIZE, -1);
this->write_raw_(&iov, 1, INDICATOR_MSG_SIZE);
#endif
}
return aerr;