Commit ed0a63ed authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

FileUtil: mark readFull() functions as FOLLY_NODISCARD

Summary:
Update readFull() and related functions to warn if their return value is
ignored.  Callers should pretty much always need to examine the return value,
as they need this to determine how much valid data was read.

Reviewed By: yfeldblum, meyering

Differential Revision: D9526760

fbshipit-source-id: c090044256bfe4bf9907a24ec6090eeae04296b3
parent 4197d896
...@@ -78,10 +78,10 @@ ssize_t writevNoInt(int fd, const iovec* iov, int count); ...@@ -78,10 +78,10 @@ ssize_t writevNoInt(int fd, const iovec* iov, int count);
* readv and preadv. The contents of iov after these functions return * readv and preadv. The contents of iov after these functions return
* is unspecified. * is unspecified.
*/ */
ssize_t readFull(int fd, void* buf, size_t n); FOLLY_NODISCARD ssize_t readFull(int fd, void* buf, size_t n);
ssize_t preadFull(int fd, void* buf, size_t n, off_t offset); FOLLY_NODISCARD ssize_t preadFull(int fd, void* buf, size_t n, off_t offset);
ssize_t readvFull(int fd, iovec* iov, int count); FOLLY_NODISCARD ssize_t readvFull(int fd, iovec* iov, int count);
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset); FOLLY_NODISCARD ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
/** /**
* Similar to readFull and preadFull above, wrappers around write() and * Similar to readFull and preadFull above, wrappers around write() and
......
...@@ -253,7 +253,8 @@ TEST(AsyncFileWriter, flush) { ...@@ -253,7 +253,8 @@ TEST(AsyncFileWriter, flush) {
// Now read from the pipe // Now read from the pipe
std::vector<char> buf; std::vector<char> buf;
buf.resize(paddingSize); buf.resize(paddingSize);
readFull(readPipe.fd(), buf.data(), buf.size()); auto bytesRead = readFull(readPipe.fd(), buf.data(), buf.size());
EXPECT_EQ(bytesRead, paddingSize);
// Make sure flush completes successfully now // Make sure flush completes successfully now
std::move(future).get(10ms); std::move(future).get(10ms);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment