Skip to content

Commit 7887259

Browse files
committed
Use optional errors.
1 parent ab2118b commit 7887259

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/storage/kv_storage/littlefs/kv_littlefs.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,15 @@ auto KeyValueStorage::put(const std::string_view key, const std::size_t size, co
114114

115115
size_t const bytes_written = std::get<size_t>(rc_write);
116116
if (bytes_written != size)
117-
{
118-
(void)_filesystem.close(file_hdl);
119-
return Error::IO;
120-
}
117+
return Error::Capacity;
121118

122119
return std::nullopt;
123120
}
124121

125122
auto KeyValueStorage::drop(const std::string_view key) -> std::optional<Error>
126123
{
127-
if (auto const err = _filesystem.remove(toFilename(key)); err != ::littlefs::Error::OK)
128-
return toError(err);
124+
if (auto const opt_err = _filesystem.remove(toFilename(key)); opt_err.has_value())
125+
return toError(opt_err.value());
129126

130127
return std::nullopt;
131128
}

0 commit comments

Comments
 (0)