diff mbox series

[FFmpeg-devel,v2] avformat/avio: fixed AVSEEK_FORCE and documentation

Message ID 20210604062818.2099-1-val.zapod.vz@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avformat/avio: fixed AVSEEK_FORCE and documentation | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Valerii Zapodovnikov June 4, 2021, 6:28 a.m. UTC
Always true expression: we would have returned on line 265,
if whence were SEEK_END we would've already returned.
Because of short circuiting force will never be checked.
Was broken since 7a6fe01f99cb95797ba59134f44b6666b1a5e792.
That is 11 years! Also fixed other commit that did confuse
ORing / passing: 41ed7ab45fc693f7d7fc35664c0233f4c32d69bb.
---
 libavformat/avio.h    | 4 ++--
 libavformat/aviobuf.c | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 0b35409787..83e2a71b67 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -505,14 +505,14 @@  int avio_put_str16be(AVIOContext *s, const char *str);
 void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type);
 
 /**
- * ORing this as the "whence" parameter to a seek function causes it to
+ * Passing this as the "whence" parameter to a seek function causes it to
  * return the filesize without seeking anywhere. Supporting this is optional.
  * If it is not supported then the seek function will return <0.
  */
 #define AVSEEK_SIZE 0x10000
 
 /**
- * Passing this flag as the "whence" parameter to a seek function causes it to
+ * OR'ing this flag into the "whence" parameter to a seek function causes it to
  * seek by any means (like reopening and linear reading) or other normally unreasonable
  * means that can be extremely slow.
  * This may be ignored by the seek code.
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index ddfa4ecbf1..d748cda397 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -286,8 +286,7 @@  int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     } else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) ||
                offset1 <= buffer_size + short_seek) &&
                !s->write_flag && offset1 >= 0 &&
-               (!s->direct || !s->seek) &&
-              (whence != SEEK_END || force)) {
+               (!s->direct || !s->seek) || force) {
         while(s->pos < offset && !s->eof_reached)
             fill_buffer(s);
         if (s->eof_reached)