From 70583db573e8e0033694e8c3d403d256f9e8cfed Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 26 Jan 2022 17:42:37 +0000 Subject: Add [[nodiscard]] to Write2 and CheckedWrite too --- fastos/src/vespa/fastos/file.cpp | 4 ++-- fastos/src/vespa/fastos/file.h | 4 ++-- fastos/src/vespa/fastos/linux_file.h | 2 +- fastos/src/vespa/fastos/unix_file.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'fastos/src') diff --git a/fastos/src/vespa/fastos/file.cpp b/fastos/src/vespa/fastos/file.cpp index fc7074d7815..4f585e7daeb 100644 --- a/fastos/src/vespa/fastos/file.cpp +++ b/fastos/src/vespa/fastos/file.cpp @@ -245,8 +245,8 @@ FastOS_FileInterface::CopyFile( const char *src, const char *dst ) do { unsigned int readBytes = s.Read( tmpBuf, bufSize ); if (readBytes > 0) { - - if ( !d.CheckedWrite( tmpBuf, readBytes)) { + ssize_t written = d.Write2(tmpBuf, readBytes); + if ( written != readBytes) { success = false; } copied += readBytes; diff --git a/fastos/src/vespa/fastos/file.h b/fastos/src/vespa/fastos/file.h index aa8f495d064..611e179adf0 100644 --- a/fastos/src/vespa/fastos/file.h +++ b/fastos/src/vespa/fastos/file.h @@ -334,7 +334,7 @@ public: * @param len number of bytes to write * @return Boolean success/failure */ - bool CheckedWrite(const void *buffer, size_t len); + [[nodiscard]] bool CheckedWrite(const void *buffer, size_t len); /** * Write [len] bytes from [buffer]. @@ -342,7 +342,7 @@ public: * @param len number of bytes to write * @return The number of bytes actually written, or -1 on error */ - virtual ssize_t Write2(const void *buffer, size_t len) = 0; + [[nodiscard]] virtual ssize_t Write2(const void *buffer, size_t len) = 0; /** * Read [length] bytes into [buffer]. Caution! If the actual number diff --git a/fastos/src/vespa/fastos/linux_file.h b/fastos/src/vespa/fastos/linux_file.h index ababf51d26d..6ba5cdc8fea 100644 --- a/fastos/src/vespa/fastos/linux_file.h +++ b/fastos/src/vespa/fastos/linux_file.h @@ -37,7 +37,7 @@ public: ssize_t Read(void *buffer, size_t len) override; - ssize_t Write2(const 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; static bool InitializeClass(); diff --git a/fastos/src/vespa/fastos/unix_file.h b/fastos/src/vespa/fastos/unix_file.h index 891b5e0dba7..86e89ffde95 100644 --- a/fastos/src/vespa/fastos/unix_file.h +++ b/fastos/src/vespa/fastos/unix_file.h @@ -59,7 +59,7 @@ public: void ReadBuf(void *buffer, size_t length, int64_t readOffset) override; ssize_t Read(void *buffer, size_t len) override; - ssize_t Write2(const 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; bool IsOpened() const override { return _filedes >= 0; } -- cgit v1.2.3