[FFmpeg-devel] [PATCH] swscale/vscale: Increase type strictness

Michael Niedermayer michael at niedermayer.cc
Mon Apr 27 21:56:23 EEST 2020


On Sun, Apr 26, 2020 at 09:49:57AM +0200, Andreas Rheinhardt wrote:
> libswscale/vscale.c makes extensive use of function pointers and in
> doing so it converts these function pointers to and from a pointer to
> void. Yet this is actually against the C standard:
> C90 only guarantees that one can convert a pointer to any incomplete
> type or object type to void* and back with the result comparing equal
> to the original which makes pointers to void generic pointers to
> incomplete or object type. Yet C90 lacks a generic function pointer
> type.
> C99 additionally guarantees that a pointer to a function of one type may
> be converted to a pointer to a function of another type and when
> converting back with the original and the result comparing equal.
> This makes any function pointer type a generic function pointer type.
> Yet even this does not make pointers to void generic function pointers.
> 
> Both GCC and Clang emit warnings for this when in pedantic mode.
> 
> This commit fixes this by using a union that can hold one member of any
> of the required function pointer types to store the function pointer.
> This works even for C90.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libswscale/vscale.c | 51 ++++++++++++++++++++++++++-------------------
>  1 file changed, 29 insertions(+), 22 deletions(-)

patch ok

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200427/fc6e652c/attachment.sig>


More information about the ffmpeg-devel mailing list