diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-01-26 19:20:01 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-01-26 19:20:01 +0000 |
commit | 3a0ab5a2d6ac2b7d94a2726862e4cd722c7c34a1 (patch) | |
tree | 49005016f300ec4fd294c296c92d1095a5cb6659 /fastos | |
parent | 70583db573e8e0033694e8c3d403d256f9e8cfed (diff) |
Add [[nodiscard]] to Read() too
Diffstat (limited to 'fastos')
-rw-r--r-- | fastos/src/tests/filetest.cpp | 3 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/file.h | 2 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/linux_file.h | 2 | ||||
-rw-r--r-- | fastos/src/vespa/fastos/unix_file.h | 2 |
4 files changed, 5 insertions, 4 deletions
diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp index d95580897d0..80045269c9e 100644 --- a/fastos/src/tests/filetest.cpp +++ b/fastos/src/tests/filetest.cpp @@ -674,7 +674,8 @@ public: int64_t position = file.GetPosition(); Progress(position == 0, "File pointer should be 0 after opening file"); - file.Read(buffer, 4); + ssize_t has_read = file.Read(buffer, 4); + Progress(has_read == 4, "Must read 4 bytes"); buffer[4] = '\0'; position = file.GetPosition(); Progress(position == 4, "File pointer should be 4 after reading 4 bytes"); diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h index 611e179adf0..238da364d54 100644 --- a/fastos/src/vespa/fastos/file.h +++ b/fastos/src/vespa/fastos/file.h @@ -324,7 +324,7 @@ public: * @return The number of bytes which was actually read, * or -1 on error. */ - virtual ssize_t Read(void *buffer, size_t length) = 0; + [[nodiscard]] virtual ssize_t Read(void *buffer, size_t length) = 0; /** * Write [len] bytes from [buffer]. This is just a wrapper for diff --git a/fastos/src/vespa/fastos/linux_file.h b/fastos/src/vespa/fastos/linux_file.h index 6ba5cdc8fea..f3c66d49f12 100644 --- a/fastos/src/vespa/fastos/linux_file.h +++ b/fastos/src/vespa/fastos/linux_file.h @@ -36,7 +36,7 @@ public: void *AllocateDirectIOBuffer(size_t byteSize, void *&realPtr) override; - ssize_t Read(void *buffer, size_t len) override; + [[nodiscard]] ssize_t Read(void *buffer, size_t len) override; [[nodiscard]] ssize_t Write2(const void *buffer, size_t len) override; bool Open(unsigned int openFlags, const char *filename) override; diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h index 86e89ffde95..70a8db5036e 100644 --- a/fastos/src/vespa/fastos/unix_file.h +++ b/fastos/src/vespa/fastos/unix_file.h @@ -58,7 +58,7 @@ public: { } void ReadBuf(void *buffer, size_t length, int64_t readOffset) override; - ssize_t Read(void *buffer, size_t len) override; + [[nodiscard]] ssize_t Read(void *buffer, size_t len) override; [[nodiscard]] ssize_t Write2(const void *buffer, size_t len) override; bool Open(unsigned int openFlags, const char *filename) override; [[nodiscard]] bool Close() override; |