diff mbox

[FFmpeg-devel] ffmpeg: add return value check to suppress the build warning.

Message ID 1A828346-9423-48E1-9CFC-A57897FE7FA1@chinaffmpeg.org
State New
Headers show

Commit Message

Liu Steven Nov. 20, 2017, 9:07 a.m. UTC
> 在 2017年11月20日,08:40,Jun Zhao <mypopydev@gmail.com> 写道:
> 
> 
> <0001-ffmpeg-add-return-value-check-to-supress-the-build-w.patch>_______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

From 01a66eb4559fb3fec0765ee03417a65ef5e06fe1 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Sat, 18 Nov 2017 13:24:24 +0800
Subject: [PATCH] ffmpeg: add return value check to supress the build warning.

add return value check to supress the build warning message like
"warning: ignoring return value" when use attribute -Wunused-result.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
---
 fftools/ffmpeg.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

Comments

Michael Niedermayer Nov. 21, 2017, 2:09 a.m. UTC | #1
On Mon, Nov 20, 2017 at 05:07:04PM +0800, 刘歧 wrote:
>
> > 在 2017年11月20日,08:40,Jun Zhao <mypopydev@gmail.com> 写道:
> >
> >
> > <0001-ffmpeg-add-return-value-check-to-supress-the-build-w.patch>_______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> From 01a66eb4559fb3fec0765ee03417a65ef5e06fe1 Mon Sep 17 00:00:00 2001
> From: Jun Zhao <jun.zhao@intel.com>
> Date: Sat, 18 Nov 2017 13:24:24 +0800
> Subject: [PATCH] ffmpeg: add return value check to supress the build warning.
>
> add return value check to supress the build warning message like
> "warning: ignoring return value" when use attribute -Wunused-result.
>
> Signed-off-by: Jun Zhao <jun.zhao@intel.com>
> ---
>  fftools/ffmpeg.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
[...]
>
> LGTM

will apply

thanks

[...]
Carl Eugen Hoyos Nov. 23, 2017, 3 a.m. UTC | #2
2017-11-20 10:07 GMT+01:00 刘歧 <lq@chinaffmpeg.org>:

> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index babd85f7bc..0c16e75ab0 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -220,13 +220,18 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts)
>  {
>      AVFrame *frame = ist->sub2video.frame;
>      int i;
> +    int ret;
>
>      av_assert1(frame->data[0]);
>      ist->sub2video.last_pts = frame->pts = pts;
> -    for (i = 0; i < ist->nb_filters; i++)
> -        av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
> -                                     AV_BUFFERSRC_FLAG_KEEP_REF |
> -                                     AV_BUFFERSRC_FLAG_PUSH);
> +    for (i = 0; i < ist->nb_filters; i++) {
> +        ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
> +                                           AV_BUFFERSRC_FLAG_KEEP_REF |
> +                                           AV_BUFFERSRC_FLAG_PUSH);
> +        if (ret != AVERROR_EOF && ret < 0)
> +            av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer source(%s).\n",

Nicolas had a comment about this change:
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-February/207015.html

Carl Eugen
Jun Zhao Nov. 23, 2017, 5:14 a.m. UTC | #3
On 2017/11/23 11:00, Carl Eugen Hoyos wrote:
> 2017-11-20 10:07 GMT+01:00 刘歧 <lq@chinaffmpeg.org>:
>
>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>> index babd85f7bc..0c16e75ab0 100644
>> --- a/fftools/ffmpeg.c
>> +++ b/fftools/ffmpeg.c
>> @@ -220,13 +220,18 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts)
>>  {
>>      AVFrame *frame = ist->sub2video.frame;
>>      int i;
>> +    int ret;
>>
>>      av_assert1(frame->data[0]);
>>      ist->sub2video.last_pts = frame->pts = pts;
>> -    for (i = 0; i < ist->nb_filters; i++)
>> -        av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
>> -                                     AV_BUFFERSRC_FLAG_KEEP_REF |
>> -                                     AV_BUFFERSRC_FLAG_PUSH);
>> +    for (i = 0; i < ist->nb_filters; i++) {
>> +        ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
>> +                                           AV_BUFFERSRC_FLAG_KEEP_REF |
>> +                                           AV_BUFFERSRC_FLAG_PUSH);
>> +        if (ret != AVERROR_EOF && ret < 0)
>> +            av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer source(%s).\n",
> Nicolas had a comment about this change:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2017-February/207015.html
>
> Carl Eugen
I didn't know you have submitted a similar patch and Nicolas had some
comments about the change
before this mail, will update the warning/error message as the comments.
Tks.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Zhanbang He Nov. 23, 2017, 6:57 a.m. UTC | #4
is it necessary to check AVERROR_EOF?

On Thu, Nov 23, 2017 at 1:14 PM, Jun Zhao <mypopydev@gmail.com> wrote:

>
>
> On 2017/11/23 11:00, Carl Eugen Hoyos wrote:
> > 2017-11-20 10:07 GMT+01:00 刘歧 <lq@chinaffmpeg.org>:
> >
> >> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> >> index babd85f7bc..0c16e75ab0 100644
> >> --- a/fftools/ffmpeg.c
> >> +++ b/fftools/ffmpeg.c
> >> @@ -220,13 +220,18 @@ static void sub2video_push_ref(InputStream *ist,
> int64_t pts)
> >>  {
> >>      AVFrame *frame = ist->sub2video.frame;
> >>      int i;
> >> +    int ret;
> >>
> >>      av_assert1(frame->data[0]);
> >>      ist->sub2video.last_pts = frame->pts = pts;
> >> -    for (i = 0; i < ist->nb_filters; i++)
> >> -        av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
> >> -                                     AV_BUFFERSRC_FLAG_KEEP_REF |
> >> -                                     AV_BUFFERSRC_FLAG_PUSH);
> >> +    for (i = 0; i < ist->nb_filters; i++) {
> >> +        ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter,
> frame,
> >> +                                           AV_BUFFERSRC_FLAG_KEEP_REF |
> >> +                                           AV_BUFFERSRC_FLAG_PUSH);
> >> +        if (ret != AVERROR_EOF && ret < 0)
> >> +            av_log(NULL, AV_LOG_WARNING, "Error while add the frame to
> buffer source(%s).\n",
> > Nicolas had a comment about this change:
> > http://ffmpeg.org/pipermail/ffmpeg-devel/2017-February/207015.html
> >
> > Carl Eugen
> I didn't know you have submitted a similar patch and Nicolas had some
> comments about the change
> before this mail, will update the warning/error message as the comments.
> Tks.
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index babd85f7bc..0c16e75ab0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -220,13 +220,18 @@  static void sub2video_push_ref(InputStream *ist, int64_t pts)
 {
     AVFrame *frame = ist->sub2video.frame;
     int i;
+    int ret;
 
     av_assert1(frame->data[0]);
     ist->sub2video.last_pts = frame->pts = pts;
-    for (i = 0; i < ist->nb_filters; i++)
-        av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
-                                     AV_BUFFERSRC_FLAG_KEEP_REF |
-                                     AV_BUFFERSRC_FLAG_PUSH);
+    for (i = 0; i < ist->nb_filters; i++) {
+        ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame,
+                                           AV_BUFFERSRC_FLAG_KEEP_REF |
+                                           AV_BUFFERSRC_FLAG_PUSH);
+        if (ret != AVERROR_EOF && ret < 0)
+            av_log(NULL, AV_LOG_WARNING, "Error while add the frame to buffer source(%s).\n",
+                   av_err2str(ret));
+    }
 }
 
 void sub2video_update(InputStream *ist, AVSubtitle *sub)
@@ -295,11 +300,15 @@  static void sub2video_heartbeat(InputStream *ist, int64_t pts)
 static void sub2video_flush(InputStream *ist)
 {
     int i;
+    int ret;
 
     if (ist->sub2video.end_pts < INT64_MAX)
         sub2video_update(ist, NULL);
-    for (i = 0; i < ist->nb_filters; i++)
-        av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
+    for (i = 0; i < ist->nb_filters; i++) {
+        ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
+        if (ret != AVERROR_EOF && ret < 0)
+            av_log(NULL, AV_LOG_WARNING, "Flush the frame error.\n");
+    }
 }
 
 /* end of sub2video hack */
@@ -327,13 +336,14 @@  static int main_return_code = 0;
 static void
 sigterm_handler(int sig)
 {
+    int ret;
     received_sigterm = sig;
     received_nb_signals++;
     term_exit_sigsafe();
     if(received_nb_signals > 3) {
-        write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n",
-                           strlen("Received > 3 system signals, hard exiting\n"));
-
+        ret = write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n",
+                    strlen("Received > 3 system signals, hard exiting\n"));
+        if (ret < 0) { /* Do nothing */ };
         exit(123);
     }
 }