diff options
-rw-r--r-- | fastlib/src/vespa/fastlib/io/bufferedfile.h | 2 | ||||
-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 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp | 3 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp | 5 |
7 files changed, 11 insertions, 8 deletions
diff --git a/fastlib/src/vespa/fastlib/io/bufferedfile.h b/fastlib/src/vespa/fastlib/io/bufferedfile.h index ab01919d91a..78c19ef8169 100644 --- a/fastlib/src/vespa/fastlib/io/bufferedfile.h +++ b/fastlib/src/vespa/fastlib/io/bufferedfile.h @@ -123,7 +123,7 @@ public: * @param dstlen The length of the destination buffer. * @return The number of bytes read. */ - ssize_t Read(void *dst, size_t dstlen) override; + [[nodiscard]] ssize_t Read(void *dst, size_t dstlen) override; /** * Write one byte to the buffered file, flushing to * file if necessary. 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; diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp index 29c82936076..f6dd5a318ae 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp @@ -53,7 +53,8 @@ BitVectorDictionary::open(const vespalib::string &pathPrefix, size_t bufSize = sizeof(WordSingleKey) * numEntries; assert(idxFile.GetSize() >= static_cast<int64_t>(idxHeaderLen + bufSize)); if (bufSize > 0) { - idxFile.Read(&_entries[0], bufSize); + ssize_t has_read = idxFile.Read(&_entries[0], bufSize); + assert(has_read == ssize_t(bufSize)); } } diff --git a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp index cd9cd6c34da..3c74ab5ff07 100644 --- a/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/wordnummapper.cpp @@ -2,6 +2,7 @@ #include "wordnummapper.h" #include <vespa/fastlib/io/bufferedfile.h> +#include <cassert> namespace search::diskindex { @@ -30,8 +31,8 @@ WordNumMapping::readMappingFile(const vespalib::string &name, map.resize(tempfileentries + 2); _oldDictSize = tempfileentries; - old2newwordfile.Read(&map[1], - static_cast<size_t>(tempfilesize)); + ssize_t has_read = old2newwordfile.Read(&map[1], static_cast<size_t>(tempfilesize)); + assert(has_read == tempfilesize); map[0] = noWordNum(); map[tempfileentries + 1] = noWordNumHigh(); } |