From ce271f82f16ee89a18e7bfc9ed8eab7cbd6f37bc Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 22 Sep 2025 23:38:21 +0200 Subject: Change io::Reader and company to return ReadError::Eof instead of 0. It's debatable if Eof should be considered an error or not. But it is pretty clear it generally is a special response that needs special handling, so easier to keep with the unexpected lot. Also keeps better at higher abstraction levels, such as the line reader. --- src/decompress_lzma.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/decompress_lzma.cc') diff --git a/src/decompress_lzma.cc b/src/decompress_lzma.cc index 6ba2976..1946075 100644 --- a/src/decompress_lzma.cc +++ b/src/decompress_lzma.cc @@ -38,7 +38,7 @@ class XzReader : public io::Reader { if (!initialized_) { if (in_eof_ && buffer_->empty()) - return 0; + return std::unexpected(io::ReadError::Eof); lzma_mt options; memset(&options, 0, sizeof(options)); @@ -89,8 +89,8 @@ class XzReader : public io::Reader { auto got = reader_->read(wptr, stream_.avail_in); if (got.has_value()) { buffer_->commit(got.value()); - if (got.value() == 0) - in_eof_ = true; + } else if (got.error() == io::ReadError::Eof) { + in_eof_ = true; } else { return got.error(); } -- cgit v1.3