* [FFmpeg-devel] [PATCH] avcodec: Explicitly use a void cast instead of av_unused in get_bits.h (PR #20840)
@ 2025-11-05 12:17 Martin Storsjö via ffmpeg-devel
2025-11-05 13:06 ` [FFmpeg-devel] " Zhao Zhili via ffmpeg-devel
0 siblings, 1 reply; 2+ messages in thread
From: Martin Storsjö via ffmpeg-devel @ 2025-11-05 12:17 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Martin Storsjö
PR #20840 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20840
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20840.patch
Currently, av_unused doesn't work when building with MSVC.
(In the future, if building in C23 mode, it could be possible
that it would work using the [[maybe_unused]] attribute though.)
Convert this specific case of silencing an unused variable to
a void cast; this silences almost 400 warnings in builds with
MSVC, getting much better signal-to-noise ratio in the warnings
there.
After this, a build with MSVC still has almost 300 warnings, but
most of the remaining ones actually do point out inconsistencies
that would be good to fix.
From bc98f30a7365e0d3368662c3946cd5d74e6f3c51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Wed, 5 Nov 2025 14:10:01 +0200
Subject: [PATCH] avcodec: Explicitly use a void cast instead of av_unused in
get_bits.h
Currently, av_unused doesn't work when building with MSVC.
(In the future, if building in C23 mode, it could be possible
that it would work using the [[maybe_unused]] attribute though.)
Convert this specific case of silencing an unused variable to
a void cast; this silences almost 400 warnings in builds with
MSVC, getting much better signal-to-noise ratio in the warnings
there.
After this, a build with MSVC still has almost 300 warnings, but
most of the remaining ones actually do point out inconsistencies
that would be good to fix.
---
libavcodec/get_bits.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 85c87c65b1..c1be4f5fcf 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -168,7 +168,8 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
#define OPEN_READER_NOSIZE(name, gb) \
unsigned int name ## _index = (gb)->index; \
- av_unused unsigned int name ## _cache
+ unsigned int name ## _cache; \
+ (void) name ## _cache
#if UNCHECKED_BITSTREAM_READER
#define OPEN_READER(name, gb) OPEN_READER_NOSIZE(name, gb)
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] Re: [PATCH] avcodec: Explicitly use a void cast instead of av_unused in get_bits.h (PR #20840)
2025-11-05 12:17 [FFmpeg-devel] [PATCH] avcodec: Explicitly use a void cast instead of av_unused in get_bits.h (PR #20840) Martin Storsjö via ffmpeg-devel
@ 2025-11-05 13:06 ` Zhao Zhili via ffmpeg-devel
0 siblings, 0 replies; 2+ messages in thread
From: Zhao Zhili via ffmpeg-devel @ 2025-11-05 13:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Cc: Martin Storsjö, Zhao Zhili
> On Nov 5, 2025, at 20:17, Martin Storsjö via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote:
>
> PR #20840 opened by Martin Storsjö (mstorsjo)
> URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20840
> Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20840.patch
>
> Currently, av_unused doesn't work when building with MSVC.
> (In the future, if building in C23 mode, it could be possible
> that it would work using the [[maybe_unused]] attribute though.)
>
> Convert this specific case of silencing an unused variable to
> a void cast; this silences almost 400 warnings in builds with
> MSVC, getting much better signal-to-noise ratio in the warnings
> there.
>
> After this, a build with MSVC still has almost 300 warnings, but
> most of the remaining ones actually do point out inconsistencies
> that would be good to fix.
>
>
> From bc98f30a7365e0d3368662c3946cd5d74e6f3c51 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
> Date: Wed, 5 Nov 2025 14:10:01 +0200
> Subject: [PATCH] avcodec: Explicitly use a void cast instead of av_unused in
> get_bits.h
>
> Currently, av_unused doesn't work when building with MSVC.
> (In the future, if building in C23 mode, it could be possible
> that it would work using the [[maybe_unused]] attribute though.)
>
> Convert this specific case of silencing an unused variable to
> a void cast; this silences almost 400 warnings in builds with
> MSVC, getting much better signal-to-noise ratio in the warnings
> there.
>
> After this, a build with MSVC still has almost 300 warnings, but
> most of the remaining ones actually do point out inconsistencies
> that would be good to fix.
> ---
> libavcodec/get_bits.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
> index 85c87c65b1..c1be4f5fcf 100644
> --- a/libavcodec/get_bits.h
> +++ b/libavcodec/get_bits.h
> @@ -168,7 +168,8 @@ static inline unsigned int show_bits(GetBitContext *s, int n);
>
> #define OPEN_READER_NOSIZE(name, gb) \
> unsigned int name ## _index = (gb)->index; \
> - av_unused unsigned int name ## _cache
> + unsigned int name ## _cache; \
> + (void) name ## _cache
LGTM. (Sorry I’m blocked by anubis due to IP address so I cannot review on code.ffmpeg)
>
> #if UNCHECKED_BITSTREAM_READER
> #define OPEN_READER(name, gb) OPEN_READER_NOSIZE(name, gb)
> --
> 2.49.1
>
> _______________________________________________
> ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
> To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-05 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-05 12:17 [FFmpeg-devel] [PATCH] avcodec: Explicitly use a void cast instead of av_unused in get_bits.h (PR #20840) Martin Storsjö via ffmpeg-devel
2025-11-05 13:06 ` [FFmpeg-devel] " Zhao Zhili via ffmpeg-devel
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