From patchwork Sun Feb 12 16:20:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 2518 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp536848vsb; Sun, 12 Feb 2017 08:21:20 -0800 (PST) X-Received: by 10.28.229.73 with SMTP id c70mr32570619wmh.82.1486916480219; Sun, 12 Feb 2017 08:21:20 -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 d75si1917410wma.105.2017.02.12.08.21.19; Sun, 12 Feb 2017 08:21:20 -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; dkim=neutral (body hash did not verify) header.i=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC82B689A70; Sun, 12 Feb 2017 18:21:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f174.google.com (mail-qt0-f174.google.com [209.85.216.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60462687EC9 for ; Sun, 12 Feb 2017 18:21:06 +0200 (EET) Received: by mail-qt0-f174.google.com with SMTP id w20so67991099qtb.1 for ; Sun, 12 Feb 2017 08:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=wfXUM8zAO/Dcig0GAhktkna4fYKXSkZ3e5qkrv+AL/I=; b=EQYOs0L6+WIPK6KWrBCrEJhVcInFXWD2oO5Bf2iMaHdo6cObR3n65w7FggEKc83u6o 6mCBPMsjDerkmSy3B2bChuaATVCSIVb9+DIVMHc4+oK1yc+iqPn1IbwWBKF9+X5boaBA PIhA1bEzrgsDJfjtozUN9hGyZSsm3+xzSw/gGqUCr1hwpkykvp+i4hnvRla5N8bTSSlO vT0TvTDzg+0uOv2nz+qIwKRWs0ruX5PEJiC1M4/8VIBWs0zlx/a+EypCATXk9LFf3/4Z lju9hCoC3urX/3wSqvoB4NLJj60krR8mK31PDnPznLqHyLjfdSHOfzIp2yAKdStMIPJ9 DuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=wfXUM8zAO/Dcig0GAhktkna4fYKXSkZ3e5qkrv+AL/I=; b=iUpGan+c7zsR6bpVyEklwat+O+6ZLSZwyzcjFQLII69lt7GkbwqxieZmI25qqvGNPD zCwxb6U2tA71TnuBaxEJXQEKWWdhP/U/Td8FfGh2XjhqKG45PMiTW8glqSO/D6kdsg3+ 1VuBuCC1j8rBx05AAidyNIGvtaqrDDIFPNlPkrbDJFP4KkfEU73ZfQk9P8erlCjXsA6S L4Li/GNbk8zhy+Ld1w5UVZcQ8RleC6zN/ZpBPlGn2CLxdtHzI4z42KpznkwIk7cpz/M/ JZmMg2yikuxG55v2bfG5b3V/+SQWL6+6MvE2EPD5+b8LatVMEQrXB1qxKfcrSPpI6ECJ Ugng== X-Gm-Message-State: AMke39lJJzzG/FZy21K8suvA/GfSKhlbE6spGWKrw/R7AATfRJndnDNG+hOlrLRtmSiIBZl07vKwPcF5P9bFYg== X-Received: by 10.237.47.230 with SMTP id m93mr16159437qtd.103.1486916469451; Sun, 12 Feb 2017 08:21:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.172.221 with HTTP; Sun, 12 Feb 2017 08:20:48 -0800 (PST) In-Reply-To: <20170212160052.GA2394197@phare.normalesup.org> References: <201702121648.57782.cehoyos@ag.or.at> <20170212160052.GA2394197@phare.normalesup.org> From: Carl Eugen Hoyos Date: Sun, 12 Feb 2017 17:20:48 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [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" 2017-02-12 17:00 GMT+01:00 Nicolas George : > Le quartidi 24 pluviôse, an CCXXV, Carl Eugen Hoyos a écrit : >> 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); > > When the changes are that small, I think it is better to fix the > indentation at the same time rather than leave it like that or fix it in > a separate commit. Done. >> + if (ret < 0) >> + av_log(ist->filters[i]->filter, AV_LOG_ERROR, > >> + "Failed to add a frame to the buffer source.\n"); > > Please mention it is a "subtitle video frame" and include the error > message itself (av_err2str(ret)). Thank you, done twice. New patch attached, Carl Eugen From 267e5e9733a073b6a6f578a5eb2199d52e05248a Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sun, 12 Feb 2017 17:17:25 +0100 Subject: [PATCH] ffmpeg: Check the return value of two functions declared "warn_unused_result". --- ffmpeg.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 06570c0..36b8132 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -215,14 +215,19 @@ 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, - 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 < 0) + av_log(ist->filters[i]->filter, AV_LOG_ERROR, + "Failed to add a subtitle video frame to the buffer source: %s\n", + av_err2str(ret)); + } } static void sub2video_update(InputStream *ist, AVSubtitle *sub) @@ -290,12 +295,17 @@ 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 subtitle video frame to the buffer source: %s\n", + av_err2str(ret)); + } } /* end of sub2video hack */ -- 1.7.10.4