From: Marton Balint via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Marton Balint <code@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avutil/opt: also print option names on parse error (PR #20348) Message-ID: <175624750619.34.580072578474141439@5a0384606a8e> (raw) 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 <cus@passwd.hu> >From 94431f8b33bc7ed84069ed02bc0e09bd8e9bb58f Mon Sep 17 00:00:00 2001 From: Marton Balint <cus@passwd.hu> 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 <cus@passwd.hu> --- 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
reply other threads:[~2025-08-26 22:32 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=175624750619.34.580072578474141439@5a0384606a8e \ --to=ffmpeg-devel@ffmpeg.org \ --cc=code@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git