From patchwork Sat Jul 15 10:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42721 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4240389pzb; Sat, 15 Jul 2023 03:50:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHdv1cXMPBdF0rg3TZ6t+/s+ZqIw9m60ObNvv12hUpOxElxH5guI07BI5i0J0x8i82Xa2Y5 X-Received: by 2002:a17:906:64d6:b0:993:d5e7:80f6 with SMTP id p22-20020a17090664d600b00993d5e780f6mr1613729ejn.5.1689418243348; Sat, 15 Jul 2023 03:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689418243; cv=none; d=google.com; s=arc-20160816; b=XnxtC9dPZWLk6DAl9cD0RCOwPTjrDLAonK5IsrOrI3fvWfAzfvGynn12EQwP1743l/ UpykynL23IlhoCAdTrQpw2/5JXip/f/UfiAmjmPAGUkmP08c9DwdMRCUCnvSJYKtRdMA ttGgs1PEkfEYie4ZK7KTHb+UsrjwDt27+sBVR3b3Ku9GRx6UYNlF6JOoOxtJHv2Oy7Mo NNqy0pR4KxsOSB+UCS10XGTu1cXYZ8efws0wBwAW+xT6d7rB+dDfGgb7itJgx763luvA sk1ER8OWeyLp7m/c1ul/IOeZvCp6lsmT1Rt0y8Z8w7W8hgQWuHmKwNLnqLxWDNyJg+zG Ax2w== 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=yS+mHh/TPZNq8MgmjWouE7W8fJlZi4djcptNmNsIGTY=; fh=8ZF2QtiKOjBtyn9wuO2cMeZaLsE4aq02Bq77gGK61E8=; b=BGe+oYT6Gz8vp3q8PqPBjMRvexDTkBLaHZFSW8TxH3LafVq4OwC+ZOPl4MBG7nVJk2 0HZSElh0R50mnPCrj7k4UGVYiKpmY2nUt534OKnVvMSAbCy0A2ZR1GjAzClVSgXJ0bxq 6WxTXkOC0X2qeigADm4PO1d4Va/InMzIzsphlz0rRqDc8jLK7k0dj5WrVs8g8f1WziBH bJKClXfnJhfoeBLPZ1n3bA7VbWuK5YecEg1Agh1q0EvbDK6SEyPcG41jXbw22sU0UOkf Agz+IccWf4Xb9FwJ8TfKoySY6phXKX9o9VWmSeTNoPKhTD4/kH9YfOXUQJUTHvVwRrDV Mj4A== 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 g10-20020a17090613ca00b00992dce29d4csi10779952ejc.874.2023.07.15.03.50.42; Sat, 15 Jul 2023 03:50:43 -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 CFDC568C75C; Sat, 15 Jul 2023 13:47:06 +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 1FE9B68C6A6 for ; Sat, 15 Jul 2023 13:46:44 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id C9DFD2404EE for ; Sat, 15 Jul 2023 12:46:43 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id och-RHO0V2ef for ; Sat, 15 Jul 2023 12:46:43 +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 156D7240D28 for ; Sat, 15 Jul 2023 12:46:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C28A93A27F9 for ; Sat, 15 Jul 2023 12:46:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 12:46:03 +0200 Message-Id: <20230715104611.17902-39-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230715104611.17902-1-anton@khirnov.net> References: <20230715104611.17902-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 39/47] fftools/cmdutils: return AVERROR_EXIT for OPT_EXIT options 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: 5tp4dzhArePN --- fftools/cmdutils.c | 2 +- fftools/ffmpeg.c | 3 +++ fftools/ffmpeg_opt.c | 2 +- fftools/ffplay.c | 2 +- fftools/ffprobe.c | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9d9d8d44a6..f37b7d44d6 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -320,7 +320,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, } } if (po->flags & OPT_EXIT) - exit_program(0); + return AVERROR_EXIT; return 0; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0c5e553c72..50d6658472 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1371,6 +1371,9 @@ int main(int argc, char **argv) err_rate_exceeded ? 69 : ret; finish: + if (ret == AVERROR_EXIT) + ret = 0; + exit_program(ret); return ret; } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 14b292f202..700db706a1 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1345,7 +1345,7 @@ int ffmpeg_parse_options(int argc, char **argv) fail: uninit_parse_context(&octx); - if (ret < 0) { + if (ret < 0 && ret != AVERROR_EXIT) { av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n", errmsg ? errmsg : "", av_err2str(ret)); } diff --git a/fftools/ffplay.c b/fftools/ffplay.c index df20c6a29d..a491fdd9e3 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3657,7 +3657,7 @@ int main(int argc, char **argv) ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) - exit(1); + exit(ret == AVERROR_EXIT ? 0 : 1); if (!input_filename) { show_usage(); diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index da8fc89830..c83d20995e 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -4129,7 +4129,7 @@ int main(int argc, char **argv) show_banner(argc, argv, options); ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) - exit_program(1); + exit_program(ret == AVERROR_EXIT ? 0 : 1); if (do_show_log) av_log_set_callback(log_callback);