summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-01-26 17:42:37 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-01-26 17:42:37 +0000
commit70583db573e8e0033694e8c3d403d256f9e8cfed (patch)
tree3054a18c93ad506937acea4d3831241a8b819e5b /fastos
parent206b56d5d561f0da77268dbee9e78c2d58ce923a (diff)
Add [[nodiscard]] to Write2 and CheckedWrite too
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/vespa/fastos/file.cpp4
-rw-r--r--fastos/src/vespa/fastos/file.h4
-rw-r--r--fastos/src/vespa/fastos/linux_file.h2
-rw-r--r--fastos/src/vespa/fastos/unix_file.h2
4 files changed, 6 insertions, 6 deletions
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; }