From 181edf4b5397ded0bb49b13a9df0a21b1806a695 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 18 Aug 2014 09:47:23 +0200 Subject: InputStream: make offset_type unsigned --- src/decoder/plugins/OpusDecoderPlugin.cxx | 3 --- src/input/AsyncInputStream.cxx | 3 --- src/input/InputStream.hxx | 5 +---- src/input/plugins/CdioParanoiaInputPlugin.cxx | 2 +- src/input/plugins/FileInputPlugin.cxx | 6 +++--- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/decoder/plugins/OpusDecoderPlugin.cxx b/src/decoder/plugins/OpusDecoderPlugin.cxx index 8d1f75e72..2ea8e0497 100644 --- a/src/decoder/plugins/OpusDecoderPlugin.cxx +++ b/src/decoder/plugins/OpusDecoderPlugin.cxx @@ -187,8 +187,6 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno, return -1; const auto old_offset = is.GetOffset(); - if (old_offset < 0) - return -1; /* create temporary Ogg objects for seeking and parsing the EOS packet */ @@ -335,7 +333,6 @@ MPDOpusDecoder::Seek(OggSyncState &oy, double where_s) assert(eos_granulepos > 0); assert(input_stream.IsSeekable()); assert(input_stream.KnownSize()); - assert(input_stream.GetOffset() >= 0); const ogg_int64_t where_granulepos(where_s * opus_sample_rate); diff --git a/src/input/AsyncInputStream.cxx b/src/input/AsyncInputStream.cxx index 8942b5116..d34ba2ff3 100644 --- a/src/input/AsyncInputStream.cxx +++ b/src/input/AsyncInputStream.cxx @@ -116,9 +116,6 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error) if (!IsSeekable()) return false; - if (new_offset < 0) - return false; - /* check if we can fast-forward the buffer */ while (new_offset > offset) { diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index f335b4642..19cf0a2de 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -35,7 +35,7 @@ struct Tag; class InputStream { public: - typedef int64_t offset_type; + typedef uint64_t offset_type; private: /** @@ -236,8 +236,6 @@ public: void AddOffset(offset_type delta) { assert(ready); - assert(offset >= 0); - assert(delta >= 0); offset += delta; } @@ -253,7 +251,6 @@ public: offset_type GetRest() const { assert(ready); assert(KnownSize()); - assert(offset >= 0); return size - offset; } diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index 6f1ea976a..f847b35c1 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -274,7 +274,7 @@ input_cdio_open(const char *uri, bool CdioParanoiaInputStream::Seek(offset_type new_offset, Error &error) { - if (new_offset < 0 || new_offset > size) { + if (new_offset > size) { error.Format(cdio_domain, "Invalid offset to seek %ld (%ld)", (long int)new_offset, (long int)size); return false; diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx index 60c316567..922c54b79 100644 --- a/src/input/plugins/FileInputPlugin.cxx +++ b/src/input/plugins/FileInputPlugin.cxx @@ -101,13 +101,13 @@ input_file_open(const char *filename, bool FileInputStream::Seek(offset_type new_offset, Error &error) { - new_offset = (offset_type)lseek(fd, (off_t)new_offset, SEEK_SET); - if (new_offset < 0) { + auto result = lseek(fd, (off_t)new_offset, SEEK_SET); + if (result < 0) { error.SetErrno("Failed to seek"); return false; } - offset = new_offset; + offset = (offset_type)result; return true; } -- cgit v1.2.3