diff mbox series

[FFmpeg-devel] avcodec/encode: change the assert0 from (ret <= 0) to (ret >= 0)

Message ID 20220628115023.54166-1-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel] avcodec/encode: change the assert0 from (ret <= 0) to (ret >= 0) | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Steven Liu June 28, 2022, 11:50 a.m. UTC
Because the codec->cb.encode return 0 is successed,
and the negative error code should failed.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavcodec/encode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Liu June 28, 2022, 12:07 p.m. UTC | #1
Andreas Rheinhardt <andreas.rheinhardt@outlook.com> 于2022年6月28日周二 19:52写道:
>
> Steven Liu:
> > Because the codec->cb.encode return 0 is successed,
> > and the negative error code should failed.
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  libavcodec/encode.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/encode.c b/libavcodec/encode.c
> > index b68bf1e184..b43a16f708 100644
> > --- a/libavcodec/encode.c
> > +++ b/libavcodec/encode.c
> > @@ -217,7 +217,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
> >              avpkt->pts = avpkt->dts = frame->pts;
> >      }
> >
> > -    av_assert0(ret <= 0);
> > +    av_assert0(ret >= 0);
> >
> >      emms_c();
> >
>
> You are asserting that encoding succeeds (and you allow encoders to
> return values > 0, which this check is meant to preclude). This is just
> wrong.
Should i only check succeeds !ret?

Thanks
Steven
diff mbox series

Patch

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index b68bf1e184..b43a16f708 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -217,7 +217,7 @@  static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
             avpkt->pts = avpkt->dts = frame->pts;
     }
 
-    av_assert0(ret <= 0);
+    av_assert0(ret >= 0);
 
     emms_c();