Conversation
…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.
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
你好,这是对 libdkapture#140 fix(dkapture): return bytes read, not remaining buffer size, 的评审。 本轮为 DKapture 两仓(libdkapture / dkapture-bpf)全部以 fix 开头 open PR 的批量评审,共 17 个;汇总表如下,本 PR 加粗。逐项详评见分隔线下方。
本 PR 评审详情作者: JoeSergen | 规模: +10/-4 | 文件: 1 总体结论: 两个 buffer 版 vector 重载原先返回循环后剩余的 bsz(未读满时近似等于总缓冲大小),与文档"读取成功时,返回读取到的数据的大小"(docs/dkapture-api.md:161-163)直接矛盾,是真实 bug。改为累加 total 返回实际写入字节数,与 read(DataType, std::vector<pid_t>&, ...) 的既有实现(so/dkapture.cpp:149-163,"return dsz - bsz")对齐,方向正确。经 grep 全仓库,demo 与 test 仅使用回调模式、单 dt/单 path 重载,无任何内部调用方依赖旧的"剩余量"语义;函数签名(含虚表布局)未变,无 ABI 结构性破坏。 主要问题: 无
亮点:
commit message: 符合规范 — fix(dkapture) 作用域正确,引用了文档契约原文,说明了与重载4对齐的理由,单一职责。 已有讨论: bot 自动评审(09-11)判定工单 #137 合规,提醒按工单步骤实际运行验证返回值(PR 未附测试);无行级评论。 |
Fixes #137
The two buffer-based overloads
read(std::vector<DataType>&, pid, buf, bsz)andread(std::vector<const char*>&, buf, bsz)returned the leftoverbszafter the loop instead of the number of bytes written, contradicting the documented contract. Accumulate the total bytes written and return that, matchingread(DataType, std::vector<pid_t>&, ...).