Skip to content

fix(dkapture): return bytes read, not remaining buffer size, in vector read()s - #140

Open
JoeSergen wants to merge 1 commit into
DKapture:mainfrom
JoeSergen:fix/dkapture-vector-read-return
Open

fix(dkapture): return bytes read, not remaining buffer size, in vector read()s#140
JoeSergen wants to merge 1 commit into
DKapture:mainfrom
JoeSergen:fix/dkapture-vector-read-return

Conversation

@JoeSergen

Copy link
Copy Markdown

Fixes #137

The two buffer-based overloads read(std::vector<DataType>&, pid, buf, bsz) and read(std::vector<const char*>&, buf, bsz) returned the leftover bsz after the loop instead of the number of bytes written, contradicting the documented contract. Accumulate the total bytes written and return that, matching read(DataType, std::vector<pid_t>&, ...).

…r read()s

The two buffer-based overloads read(std::vector<DataType>&, pid, buf,
bsz) and read(std::vector<const char*>&, buf, bsz) returned the
leftover bsz after the loop instead of the number of bytes written,
contradicting the documented contract ('success returns the number of
bytes read'). Accumulate total bytes written and return that, matching
the read(DataType, std::vector<pid_t>&, ...) overload.
@xu-lang

xu-lang commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

137 - PR Code Verified

Compliant requirements:

  • 两个 vector 重载均新增 total 累加变量并返回实际写入字节数,不再返回剩余 bsz
  • 循环条件改为 ret <= 0 时 continue,并新增 assert((size_t)ret <= bsz),与工单期望实现一致
  • 返回值语义与 read(DataType, std::vector<pid_t>&, ...) 对齐

Requires further human verification:

  • 按工单复现步骤实际运行,验证返回值等于实际写入字节数(本 PR 未附带测试)
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: dkapture::read() 两个 vector 重载返回剩余缓冲区大小而非已读字节数

2 participants