diff --git a/lab/vtpc/test/lib/file.cpp b/lab/vtpc/test/lib/file.cpp index dff8ed9..c2d7f64 100644 --- a/lab/vtpc/test/lib/file.cpp +++ b/lab/vtpc/test/lib/file.cpp @@ -40,11 +40,18 @@ struct io { std::function fsync; }; -template -void robust_do(A action, int fd, auto buf, size_t count) { +template +void robust_do(A action, int fd, T* buf, size_t count) { + using B = std::conditional_t< + std::is_const_v>, + const char, + char>; + size_t total = 0; while (total < count) { - const ssize_t local = action(fd, buf, count); + const size_t tail_count = count - total; + B* tail_buf = reinterpret_cast(buf) + total; // NOLINT + const ssize_t local = action(fd, tail_buf, tail_count); if (local < 0) { throw vt::file_exception(local) << "failed to read/write " << count << " bytes from file with fd "