This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 2e5083175524ae69f9e19eaff5caa0c14353c6a5 Author: Ramiro Polla <[email protected]> AuthorDate: Fri May 1 17:42:55 2026 +0200 Commit: Ramiro Polla <[email protected]> CommitDate: Thu Jun 4 22:54:27 2026 +0200 swscale/tests/swscale: propagate ret out of parse_options() This will make it easier to keep function-scoped variables. Sponsored-by: Sovereign Tech Fund Signed-off-by: Ramiro Polla <[email protected]> --- libswscale/tests/swscale.c | 47 ++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c index 881c85faaa..2d7dfdf7e5 100644 --- a/libswscale/tests/swscale.c +++ b/libswscale/tests/swscale.c @@ -853,6 +853,8 @@ error: static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) { + int ret; + for (int i = 1; i < argc; i += 2) { if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { fprintf(stderr, @@ -905,32 +907,36 @@ static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) *fp = fopen(argv[i + 1], "r"); if (!*fp) { fprintf(stderr, "could not open '%s'\n", argv[i + 1]); - return -1; + ret = AVERROR(errno); + goto end; } } else if (!strcmp(argv[i], "-cpuflags")) { unsigned flags = av_get_cpu_flags(); - int res = av_parse_cpu_caps(&flags, argv[i + 1]); - if (res < 0) { + ret = av_parse_cpu_caps(&flags, argv[i + 1]); + if (ret < 0) { fprintf(stderr, "invalid cpu flags %s\n", argv[i + 1]); - return -1; + goto end; } av_force_cpu_flags(flags); } else if (!strcmp(argv[i], "-src")) { opts->src_fmt = av_get_pix_fmt(argv[i + 1]); if (opts->src_fmt == AV_PIX_FMT_NONE) { fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]); - return -1; + ret = AVERROR(EINVAL); + goto end; } } else if (!strcmp(argv[i], "-dst")) { opts->dst_fmt = av_get_pix_fmt(argv[i + 1]); if (opts->dst_fmt == AV_PIX_FMT_NONE) { fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]); - return -1; + ret = AVERROR(EINVAL); + goto end; } } else if (!strcmp(argv[i], "-s")) { if (av_parse_video_size(&opts->w, &opts->h, argv[i + 1]) < 0) { fprintf(stderr, "invalid frame size %s\n", argv[i + 1]); - return -1; + ret = AVERROR(EINVAL); + goto end; } } else if (!strcmp(argv[i], "-bench")) { int iters = atoi(argv[i + 1]); @@ -944,20 +950,20 @@ static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) } else if (!strcmp(argv[i], "-flags")) { SwsContext *dummy = sws_alloc_context(); const AVOption *flags_opt = av_opt_find(dummy, "sws_flags", NULL, 0, 0); - int ret = av_opt_eval_flags(dummy, flags_opt, argv[i + 1], &opts->flags); + ret = av_opt_eval_flags(dummy, flags_opt, argv[i + 1], &opts->flags); sws_free_context(&dummy); if (ret < 0) { fprintf(stderr, "invalid flags %s\n", argv[i + 1]); - return -1; + goto end; } } else if (!strcmp(argv[i], "-backends")) { SwsContext *dummy = sws_alloc_context(); const AVOption *backends_opt = av_opt_find(dummy, "sws_backends", NULL, 0, 0); - int ret = av_opt_eval_flags(dummy, backends_opt, argv[i + 1], &opts->backends); + ret = av_opt_eval_flags(dummy, backends_opt, argv[i + 1], &opts->backends); sws_free_context(&dummy); if (ret < 0) { fprintf(stderr, "invalid backends %s\n", argv[i + 1]); - return -1; + goto end; } } else if (!strcmp(argv[i], "-dither")) { opts->dither = atoi(argv[i + 1]); @@ -978,20 +984,21 @@ static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) } else if (!strcmp(argv[i], "-legacy")) { opts->legacy = atoi(argv[i + 1]); } else if (!strcmp(argv[i], "-hw")) { - int ret = av_hwdevice_ctx_create(&hw_device_ctx, - AV_HWDEVICE_TYPE_VULKAN, - argv[i + 1], NULL, 0); + ret = av_hwdevice_ctx_create(&hw_device_ctx, + AV_HWDEVICE_TYPE_VULKAN, + argv[i + 1], NULL, 0); if (ret < 0) { fprintf(stderr, "Failed to create Vulkan device '%s'\n", argv[i + 1]); - return -1; + goto end; } hw_device_constr = av_hwdevice_get_hwframe_constraints(hw_device_ctx, NULL); if (!hw_device_constr) { fprintf(stderr, "Failed to retrieve Vulkan device constraints '%s'\n", argv[i + 1]); - return -1; + ret = AVERROR(ENOMEM); + goto end; } } else if (!strcmp(argv[i], "-threads")) { opts->threads = atoi(argv[i + 1]); @@ -1004,7 +1011,8 @@ static int parse_options(int argc, char **argv, struct options *opts, FILE **fp) } else { bad_option: fprintf(stderr, "bad option or argument missing (%s) see -help\n", argv[i]); - return -1; + ret = AVERROR(EINVAL); + goto end; } } @@ -1013,7 +1021,10 @@ bad_option: opts->h = opts->bench ? 1080 : 96; } - return 0; + ret = 0; + +end: + return ret; } int main(int argc, char **argv) _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
