From patchwork Thu Jul 13 10:55:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42635 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp2822277pzb; Thu, 13 Jul 2023 03:58:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlFSZYbd6ISzXrrIGz/yGuuiyZvfX0JhW6ApGX4PgDyhKFrBgt4sz+Vh7oGXWYNUA9jb+L7h X-Received: by 2002:aa7:c654:0:b0:519:6a6a:7659 with SMTP id z20-20020aa7c654000000b005196a6a7659mr1456887edr.18.1689245880033; Thu, 13 Jul 2023 03:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689245880; cv=none; d=google.com; s=arc-20160816; b=gTOMUn4BGfwQSfOb2PlifSwwO9vQXWUTTc41tML9TIyj2p6TmEXNiMqVzTwqNnkjU4 5alNNbN2+wnABxkPQ/3+QoABKMwj0OiOQWnpu08mHBuvSc9S22WOGn/npww8FOe4m7J2 rREOwEEU8wSNFIL6ewfVBW6EZ4FpePtCVIddqVabNEslsrEcc5Ss6hKIUjSBSTkz+JjN wSRwJsrv+/hbEVpRJVJPPKAbU7cY/L5tCTrL5r55iSe2YSsQsWYta3HaXGS3Vr5xajMQ LiImtRXqRUJ4iIjaXSzUHpznNkh5RxudLM+70vwIo4xQn7OLWT9aD4JuW+XM+vVPDUFk XQ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=r5KmGB73bvBmraWEQd1pzoz5WNHYNisEOXDZY8RdkKI=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=IlQR5ilzyX/7/8O/hV3yKV/gzIZgaYuGGTydfX+RtviUi+bPDKoLOHiFe9j7ROZZtF 76u7AVtAv2z1MM5HV8ZbuQqvX9fcsRV77Xsndz9n+S7Fgj0fuLt/JvS8iLoFYuuvS3Ts l/YTnUuw0oJEAM+hdPss7Ocfb2S1FS7nnAMlPnqGgIl5fqZa+VwlD8qga8I/WOoQU/CH BRgthgkkPHvyVJkwHU31QuO5Pg//jcKtnjc1vl3A0yq0R/Yg+sPNajice42tRm2ZGE9Y 1e8YQw31sQqUqimRkxjY1fwsdPJeZsOqOWAG8HriHMMmZQaje960OwrX2Hz+3RecjrJb loZg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e3-20020a50ec83000000b0051e247f2828si7254115edr.91.2023.07.13.03.57.59; Thu, 13 Jul 2023 03:58:00 -0700 (PDT) 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 77E7768C633; Thu, 13 Jul 2023 13:57:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB39868C32F for ; Thu, 13 Jul 2023 13:57:42 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6FEBB2404EE for ; Thu, 13 Jul 2023 12:57:42 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id eui5P5PxxVJW for ; Thu, 13 Jul 2023 12:57:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6EF482404F8 for ; Thu, 13 Jul 2023 12:57:41 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 205153A1074 for ; Thu, 13 Jul 2023 12:57:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jul 2023 12:55:24 +0200 Message-Id: <20230713105553.21052-4-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713105553.21052-1-anton@khirnov.net> References: <20230713105553.21052-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/33] fftools/ffmpeg_demux: forward errors from dump_attachment() instead of aborting X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: yp1hLjgsDZz3 Also, check the return code of avio_close(). --- fftools/ffmpeg_demux.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 40bbfa0c0e..498830098d 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1259,7 +1259,7 @@ static void ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ist->codec_desc = avcodec_descriptor_get(ist->par->codec_id); } -static void dump_attachment(InputStream *ist, const char *filename) +static int dump_attachment(InputStream *ist, const char *filename) { AVStream *st = ist->st; int ret; @@ -1268,13 +1268,13 @@ static void dump_attachment(InputStream *ist, const char *filename) if (!st->codecpar->extradata_size) { av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n"); - return; + return 0; } if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) filename = e->value; if (!*filename) { av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag"); - exit_program(1); + return AVERROR(EINVAL); } assert_file_overwrite(filename); @@ -1282,11 +1282,13 @@ static void dump_attachment(InputStream *ist, const char *filename) if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { av_log(ist, AV_LOG_FATAL, "Could not open file %s for writing.\n", filename); - exit_program(1); + return ret; } avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size); - avio_close(out); + ret = avio_close(out); + + return ret; } static const char *input_file_item_name(void *obj) @@ -1617,8 +1619,11 @@ int ifile_open(const OptionsContext *o, const char *filename) for (j = 0; j < f->nb_streams; j++) { InputStream *ist = f->streams[j]; - if (check_stream_specifier(ic, ist->st, o->dump_attachment[i].specifier) == 1) - dump_attachment(ist, o->dump_attachment[i].u.str); + if (check_stream_specifier(ic, ist->st, o->dump_attachment[i].specifier) == 1) { + ret = dump_attachment(ist, o->dump_attachment[i].u.str); + if (ret < 0) + return ret; + } } }