From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id BA10D4BB77 for ; Tue, 26 Aug 2025 22:32:29 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'PjJ3WAKhlzG6TN22vmtXHWQrFc/T6TU/K7M6yCqbjEA=', expected b'zXJu4464n94CvFzmWkn6OBLfav+uKG9dT07kSsMsCxg=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756247532; h=mime-version : to : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=PjJ3WAKhlzG6TN22vmtXHWQrFc/T6TU/K7M6yCqbjEA=; b=sw+Nyg1QQ04iPbrFBbiluygWhwwjffvXh4Ji7qbfRiENzJgLLc6S6Yzb90/ymjOzVM8R7 s6aFbdzv7ROh7mtPzuu6qdV6+wXv+LN9kJ1wQiatidgOaH9jbD+wU9W/q5z12QDz/MzFp2i 0rznxCiDXHWwzK/d0NzD4fefyuXMzVGQEt3RDxk+0Hc2EL+ZIBSmyNjqh6x8cZXV/4vKEmW 586coQ5ZPdb2GWRLdN02elLsbpIfJDCgzVv85zPnS/m/Xu+qLebrBhPD2M37iR/3OyuvlLd wy07eK4/JRpHqOePLgcaQ81Dr3TIuQWwJTXRqwVdc9wwFiFCDhbPM/42JjxQ== Received: from [172.18.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id CAA5A68E779; Wed, 27 Aug 2025 01:32:12 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1756247513; b=ivJ/KDzslb5aBG8xkZteTVu2ji+mbTPCXvtPzYYXpc98N2+fme5RWBLqEjtwcEjEKeS5h plIB9asSi/lrLIlDj+wfAMd9T7tZW7jx2towemV4rNHPdCM9rRHitrEBlXSgfZlOJvSo89x +xpBiAzzzfpu8BKCjQvniyldaEPkFnM07GLVTTFnt/r1dY0Q0xbhOSIINBziF3r5A0FzBK5 sSCca8a5FHCb6H8da//xfwRsOWzzGcWbsqUJb5pWPk12kfjfEuzNg+QDzptF16+hP8hrqm+ 66nd57/Cr9Zq7QBJKauw6R6miSEyF0gaiOq7NNnKpV65/YN94HHNjgF3PzDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1756247513; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=ouBCfaJvWVzq/DZd3YIj2awwNUks+bDsm/SgZSR3Onw=; b=suKMLxMY4P11wsEcWTpAbTmhg3iCjkmOG78FvLSO65u1fiTQDvm0x+dCFi9Huo64wAflp j3S3lBMjMTWCTpDyf5/elk2u7Viry/rSIKQFi8pushvG71Hsa7YKqFJckvPaV3b+MXl5Zgi d2G3yQEnFP1lospSEPHoBb5iFQw23qsjRXYZPyu+xDmz1uReEf7Rv2h7YCknGouXVcaT5TM pZnN4cyQ3rW4Za68eljOD4t6SAkzLhBH5su+NPs/j67LBNoKewlAIQKnzF4Goku/6+kaDZ/ Iy22DRTXzE2g4MD3xOC/bnjrtcfQrbYSZy/Af9DfaWZzIpER0vlRRYyo8sTw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756247505; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : from; bh=zXJu4464n94CvFzmWkn6OBLfav+uKG9dT07kSsMsCxg=; b=nmBl0VCNtbZ/5eAREabnvO2PUgnJSSmr13X7B0TkuThIMGp989p0ISuCsg7SGUaVSnSuw Q4HLEX99XpLTCpC0JwgKOnvKvQHFfMNpW6uHz2RKUgQ+MfBGOxF+aOmoN9PBhG9YaA1aC3Q 9ldfv/6YIMXliYZtIschfWSHOjkYXCRRYixzTYfVnrUtB7THFumj3vNawMXyz6pwwIeeqXG H2jsu3HzAYWZv5HWS8OQjz5UOs9lD6I9L3hWe1cDu1v1o5hbd6ckzoqlZjna/uEtDs/+oZt vizFHICn8EvAd8mfgTGRjwXHQQq3XevI3uyDi7KQqx6j3mUbjg3jIAfKO8SA== Received: from 5d8f51c41678 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id D8C856801B2 for ; Wed, 27 Aug 2025 01:31:45 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Message-ID: <175624750619.34.580072578474141439@5a0384606a8e> Message-ID-Hash: UI53S5V2J5N5K5IKSJEVWPRPQFWLQ4IQ X-Message-ID-Hash: UI53S5V2J5N5K5IKSJEVWPRPQFWLQ4IQ X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avutil/opt: also print option names on parse error (PR #20348) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Marton Balint via ffmpeg-devel Cc: Marton Balint Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20348 opened by Marton Balint (cus) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20348 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20348.patch It is more user-friendly to print which option caused the parse error. Signed-off-by: Marton Balint >>From 94431f8b33bc7ed84069ed02bc0e09bd8e9bb58f Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Wed, 27 Aug 2025 00:15:31 +0200 Subject: [PATCH] avutil/opt: also print option names on parse error It is more user-friendly to print which option caused the parse error. Signed-off-by: Marton Balint --- libavutil/opt.c | 16 ++++++++-------- tests/ref/fate/opt | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 7a84a18bb5..fc5834e168 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -490,7 +490,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con res = av_expr_parse_and_eval(&d, i ? buf : val, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); if (res < 0) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\"\n", o->name, val); return res; } } @@ -522,7 +522,7 @@ static int set_string_image_size(void *obj, const AVOption *o, const char *val, } ret = av_parse_video_size(dst, dst + 1, val); if (ret < 0) - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as image size\n", o->name, val); return ret; } @@ -530,7 +530,7 @@ static int set_string_video_rate(void *obj, const AVOption *o, const char *val, { int ret = av_parse_video_rate(dst, val); if (ret < 0) - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as video rate\n", o->name, val); return ret; } @@ -543,7 +543,7 @@ static int set_string_color(void *obj, const AVOption *o, const char *val, uint8 } else { ret = av_parse_color(dst, val, -1, obj); if (ret < 0) - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as color\n", o->name, val); return ret; } return 0; @@ -583,7 +583,7 @@ static int set_string_bool(void *obj, const AVOption *o, const char *val, int *d return 0; fail: - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as boolean\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as boolean\n", o->name, val); return AVERROR(EINVAL); } @@ -601,7 +601,7 @@ static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t fmt = strtol(val, &tail, 0); if (*tail || (unsigned)fmt >= fmt_nb) { av_log(obj, AV_LOG_ERROR, - "Unable to parse option value \"%s\" as %s\n", val, desc); + "Unable to parse \"%s\" option value \"%s\" as %s\n", o->name, val, desc); return AVERROR(EINVAL); } } @@ -724,7 +724,7 @@ static int opt_set_elem(void *obj, void *target_obj, const AVOption *o, int64_t usecs = 0; if (val) { if ((ret = av_parse_time(&usecs, val, 1)) < 0) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as duration\n", o->name, val); return ret; } } @@ -741,7 +741,7 @@ static int opt_set_elem(void *obj, void *target_obj, const AVOption *o, case AV_OPT_TYPE_CHLAYOUT: ret = set_string_channel_layout(obj, o, val, dst); if (ret < 0) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", val); + av_log(obj, AV_LOG_ERROR, "Unable to parse \"%s\" option value \"%s\" as channel layout\n", o->name, val); ret = AVERROR(EINVAL); } return ret; diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt index b8812e3eff..1f82f7e4bd 100644 --- a/tests/ref/fate/opt +++ b/tests/ref/fate/opt @@ -231,7 +231,7 @@ Error 'foo==val' Setting options string 'toggle=:' Setting entry with key 'toggle' to value '' Undefined constant or missing '(' in '' -Unable to parse option value "" +Unable to parse "toggle" option value "" Error 'toggle=:' Setting options string 'string=:' Setting entry with key 'string' to value '' @@ -247,7 +247,7 @@ Error 'toggle=100' Setting options string 'toggle==1' Setting entry with key 'toggle' to value '=1' Undefined constant or missing '(' in '=1' -Unable to parse option value "=1" +Unable to parse "toggle" option value "=1" Error 'toggle==1' Setting options string 'flags=+mu-lame : num=42: toggle=0' Setting entry with key 'flags' to value '+mu-lame' @@ -275,7 +275,7 @@ Setting entry with key 'size' to value 'pal' OK 'size=pal' Setting options string 'size=bogus' Setting entry with key 'size' to value 'bogus' -Unable to parse option value "bogus" as image size +Unable to parse "size" option value "bogus" as image size Error 'size=bogus' Setting options string 'pix_fmt=yuv420p' Setting entry with key 'pix_fmt' to value 'yuv420p' @@ -285,7 +285,7 @@ Setting entry with key 'pix_fmt' to value '2' OK 'pix_fmt=2' Setting options string 'pix_fmt=bogus' Setting entry with key 'pix_fmt' to value 'bogus' -Unable to parse option value "bogus" as pixel format +Unable to parse "pix_fmt" option value "bogus" as pixel format Error 'pix_fmt=bogus' Setting options string 'sample_fmt=s16' Setting entry with key 'sample_fmt' to value 's16' @@ -295,7 +295,7 @@ Setting entry with key 'sample_fmt' to value '2' OK 'sample_fmt=2' Setting options string 'sample_fmt=bogus' Setting entry with key 'sample_fmt' to value 'bogus' -Unable to parse option value "bogus" as sample format +Unable to parse "sample_fmt" option value "bogus" as sample format Error 'sample_fmt=bogus' Setting options string 'video_rate=pal' Setting entry with key 'video_rate' to value 'pal' @@ -312,11 +312,11 @@ OK 'video_rate=30/1.001' Setting options string 'video_rate=bogus' Setting entry with key 'video_rate' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" as video rate +Unable to parse "video_rate" option value "bogus" as video rate Error 'video_rate=bogus' Setting options string 'duration=bogus' Setting entry with key 'duration' to value 'bogus' -Unable to parse option value "bogus" as duration +Unable to parse "duration" option value "bogus" as duration Error 'duration=bogus' Setting options string 'duration=123.45' Setting entry with key 'duration' to value '123.45' @@ -338,7 +338,7 @@ Setting entry with key 'cl' to value 'FL+FR' OK 'cl=FL+FR' Setting options string 'cl=foo' Setting entry with key 'cl' to value 'foo' -Unable to parse option value "foo" as channel layout +Unable to parse "cl" option value "foo" as channel layout Error 'cl=foo' Setting options string 'bin=boguss' Setting entry with key 'bin' to value 'boguss' @@ -352,7 +352,7 @@ OK 'bin=ffff' Setting options string 'num=bogus' Setting entry with key 'num' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" +Unable to parse "num" option value "bogus" Error 'num=bogus' Setting options string 'num=44' Setting entry with key 'num' to value '44' @@ -374,7 +374,7 @@ Error 'num=101' Setting options string 'unum=bogus' Setting entry with key 'unum' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" +Unable to parse "unum" option value "bogus" Error 'unum=bogus' Setting options string 'unum=44' Setting entry with key 'unum' to value '44' @@ -396,7 +396,7 @@ Error 'unum=2147483649' Setting options string 'num64=bogus' Setting entry with key 'num64' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" +Unable to parse "num64" option value "bogus" Error 'num64=bogus' Setting options string 'num64=44' Setting entry with key 'num64' to value '44' @@ -421,7 +421,7 @@ Error 'num64=4294967297' Setting options string 'flt=bogus' Setting entry with key 'flt' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" +Unable to parse "flt" option value "bogus" Error 'flt=bogus' Setting options string 'flt=2' Setting entry with key 'flt' to value '2' @@ -440,7 +440,7 @@ Error 'flt=101' Setting options string 'dbl=bogus' Setting entry with key 'dbl' to value 'bogus' Undefined constant or missing '(' in 'bogus' -Unable to parse option value "bogus" +Unable to parse "dbl" option value "bogus" Error 'dbl=bogus' Setting options string 'dbl=2' Setting entry with key 'dbl' to value '2' @@ -496,7 +496,7 @@ Error '5:size=pal:hello' Setting options string ':' Setting 'num' to value '' Undefined constant or missing '(' in '' -Unable to parse option value "" +Unable to parse "num" option value "" Error ':' Setting options string '=' Setting '' to value '' -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org