From patchwork Sun Feb 12 15:48:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 2517 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp526278vsb; Sun, 12 Feb 2017 07:49:12 -0800 (PST) X-Received: by 10.223.139.12 with SMTP id n12mr15729102wra.176.1486914552713; Sun, 12 Feb 2017 07:49:12 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j53si10105405wra.334.2017.02.12.07.49.12; Sun, 12 Feb 2017 07:49:12 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6211689C98; Sun, 12 Feb 2017 17:49:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-1.mx.upcmail.net (vie01a-dmta-pe03-1.mx.upcmail.net [62.179.121.160]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A5716897ED for ; Sun, 12 Feb 2017 17:48:58 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1ccwOc-0007jY-1p for ffmpeg-devel@ffmpeg.org; Sun, 12 Feb 2017 16:49:02 +0100 Received: from [192.168.1.3] ([80.110.104.170]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id jrox1u01V3gbyXk01roycE; Sun, 12 Feb 2017 16:48:59 +0100 X-SourceIP: 80.110.104.170 From: Carl Eugen Hoyos To: FFmpeg development discussions and patches Date: Sun, 12 Feb 2017 16:48:57 +0100 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Message-Id: <201702121648.57782.cehoyos@ag.or.at> Subject: [FFmpeg-devel] [PATCH]ffmpeg: Check the return values of two functions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi! Attached patch written yesterday silences warnings when compiling ffmpeg.c, don't know how useful it is, only fate-tested. Please comment, Carl Eugen From 525aff909aec50d4e1a49f289ff9069300a4b51f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 12 Feb 2017 16:41:21 +0100 Subject: [PATCH] ffmpeg: Check the return value of two functions declared "warn_unused_result". --- ffmpeg.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 06570c0..9952da6 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -215,14 +215,18 @@ static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, static void sub2video_push_ref(InputStream *ist, int64_t pts) { AVFrame *frame = ist->sub2video.frame; - int i; + int i, 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, + 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 < 0) + av_log(ist->filters[i]->filter, AV_LOG_ERROR, + "Failed to add a frame to the buffer source.\n"); + } } static void sub2video_update(InputStream *ist, AVSubtitle *sub) @@ -290,12 +294,16 @@ static void sub2video_heartbeat(InputStream *ist, int64_t pts) static void sub2video_flush(InputStream *ist) { - int i; + int i, 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 < 0) + av_log(ist->filters[i]->filter, AV_LOG_ERROR, + "Failed to add a frame to the buffer source.\n"); + } } /* end of sub2video hack */