[libc-commits] [PATCH] D127238: [libc] Fix a bug in file write logic.

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 8 10:14:06 PDT 2022


michaelrj added inline comments.


================
Comment at: libc/src/__support/File/file.cpp:63
     for (size_t i = 0; i < remaining; ++i)
       bufref[i] = dataref[i];
     pos += remaining;
----------------
needs to be `dataref[i+write_size]`


================
Comment at: libc/test/src/__support/File/file_test.cpp:135
   ASSERT_EQ(f->flush(), 0);
   EXPECT_EQ(f->get_pos(), 2 * sizeof(data));
 
----------------
add the following to prevent regressions:
```
  MemoryView src1("hello, file\0hello, file", sizeof(data) * 2),
      dst1(f->get_str(), sizeof(data) * 2);
  EXPECT_MEM_EQ(src1, dst1);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127238/new/

https://reviews.llvm.org/D127238



More information about the libc-commits mailing list