Message ID | 20190719122354.32460-2-george@nsup.org |
---|---|
State | Accepted |
Commit | 6e1a2dc11236fb04acf35bde647872eb4f3ded9c |
Headers | show |
On Fri, Jul 19, 2019 at 02:23:53PM +0200, Nicolas George wrote: > Signed-off-by: Nicolas George <george@nsup.org> > --- > libavformat/aviobuf.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > index 6a5cd97b0a..750326f62d 100644 > --- a/libavformat/aviobuf.c > +++ b/libavformat/aviobuf.c > @@ -255,6 +255,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) > if(!s) > return AVERROR(EINVAL); > > + if ((whence & AVSEEK_SIZE)) redundant () > + return s->seek ? s->seek(s->opaque, offset, AVSEEK_SIZE) : AVERROR(ENOSYS); > + seems like a good idea Thanks [...]
Michael Niedermayer (12019-07-19): > > + if ((whence & AVSEEK_SIZE)) > redundant () I use it as a marker that it is not a mistake for &&. IIRC, gcc (with some options) warns about "if (a & b)" but accepts "if ((a & b))", and that is the preferred way. We already have a few instances in the code base, not all of them mine. Regards,
On Fri, Jul 19, 2019 at 11:49 PM Nicolas George <george@nsup.org> wrote: > > Michael Niedermayer (12019-07-19): > > > + if ((whence & AVSEEK_SIZE)) > > redundant () > > I use it as a marker that it is not a mistake for &&. IIRC, gcc (with > some options) warns about "if (a & b)" but accepts "if ((a & b))", and > that is the preferred way. We already have a few instances in the code > base, not all of them mine. > That seems like a particularly dumb compiler "feature". Checking bitmasks for a set bit seems like a rather standard if condition. - Hendril
Hendrik Leppkes (12019-07-20): > That seems like a particularly dumb compiler "feature". Checking > bitmasks for a set bit seems like a rather standard if condition. Maybe, to each their own, but it saved me a few times, so personally I like it, especially since the double-parentheses is an obvious and unobtrusive way of silencing it. (Personally I would prefer explicitly "!= 0", but that is not FFmpeg's coding style.) Regards,
On Fri, Jul 19, 2019 at 11:49:04PM +0200, Nicolas George wrote: > Michael Niedermayer (12019-07-19): > > > + if ((whence & AVSEEK_SIZE)) > > redundant () > > I use it as a marker that it is not a mistake for &&. IIRC, gcc (with > some options) warns about "if (a & b)" but accepts "if ((a & b))", and > that is the preferred way. We already have a few instances in the code > base, not all of them mine. ok, just mentioned it as i thought it was unintended. If the () is intended, ignore my comment thx [...]
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 6a5cd97b0a..750326f62d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -255,6 +255,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) if(!s) return AVERROR(EINVAL); + if ((whence & AVSEEK_SIZE)) + return s->seek ? s->seek(s->opaque, offset, AVSEEK_SIZE) : AVERROR(ENOSYS); + buffer_size = s->buf_end - s->buffer; // pos is the absolute position that the beginning of s->buffer corresponds to in the file pos = s->pos - (s->write_flag ? 0 : buffer_size);
Signed-off-by: Nicolas George <george@nsup.org> --- libavformat/aviobuf.c | 3 +++ 1 file changed, 3 insertions(+)