Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Mark Thompson <sw@jkqxz.net>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 2/3] avutil/opt: Use correct function pointer type
Date: Sat, 24 Feb 2024 12:09:41 +0000
Message-ID: <830a8be0-596e-4102-9472-bbaa78307b89@jkqxz.net> (raw)
In-Reply-To: <AS8P250MB07448E8BC3024C7D581C07818F572@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

On 21/02/2024 23:32, Andreas Rheinhardt wrote:
> av_get_sample/pix_fmt() return their respective enums
> and are therefore not of the type int (*)(const char*),
> yet they are called as-if they were of this type.
> This works in practice, but is actually undefined behaviour.
> 
> With Clang 17 UBSan these violations are flagged, affecting lots
> of tests. The number of failing tests went down from 3363 to 164
> here with this patch.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   libavutil/opt.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index d13b1ab504..0681b19896 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -444,16 +444,26 @@ static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t
>       return 0;
>   }
>   
> +static int get_pix_fmt(const char *name)
> +{
> +    return av_get_pix_fmt(name);
> +}
> +
>   static int set_string_pixel_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst)
>   {
>       return set_string_fmt(obj, o, val, dst,
> -                          AV_PIX_FMT_NB, av_get_pix_fmt, "pixel format");
> +                          AV_PIX_FMT_NB, get_pix_fmt, "pixel format");
> +}
> +
> +static int get_sample_fmt(const char *name)
> +{
> +    return av_get_sample_fmt(name);
>   }
>   
>   static int set_string_sample_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst)
>   {
>       return set_string_fmt(obj, o, val, dst,
> -                          AV_SAMPLE_FMT_NB, av_get_sample_fmt, "sample format");
> +                          AV_SAMPLE_FMT_NB, get_sample_fmt, "sample format");
>   }
>   
>   static int set_string_dict(void *obj, const AVOption *o, const char *val, uint8_t **dst)

1 and 2 of this set LGTM.

Thanks,

- Mark
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-02-24 12:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 23:31 [FFmpeg-devel] [PATCH 1/3] avcodec/cbs_h266_syntax_template: Don't omit unused function parameter Andreas Rheinhardt
2024-02-21 23:32 ` [FFmpeg-devel] [PATCH 2/3] avutil/opt: Use correct function pointer type Andreas Rheinhardt
2024-02-24 12:09   ` Mark Thompson [this message]
2024-02-21 23:32 ` [FFmpeg-devel] [PATCH 3/3] avcodec/cbs_h2645: Avoid function pointer casts, fix UB Andreas Rheinhardt
2024-02-24 12:06   ` Mark Thompson
2024-02-24 14:46     ` Andreas Rheinhardt
2024-02-24  2:51 ` [FFmpeg-devel] [PATCH 1/3] avcodec/cbs_h266_syntax_template: Don't omit unused function parameter Andreas Rheinhardt

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=830a8be0-596e-4102-9472-bbaa78307b89@jkqxz.net \
    --to=sw@jkqxz.net \
    --cc=ffmpeg-devel@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