• Andreas Rheinhardt's avatar
    fftools: Use right function signature and pointers · f2d522f2
    Andreas Rheinhardt authored
    The option tables of the various fftools (in particular ffprobe) are
    arrays of OptionDef; said type contains a union of a pointer to void and
    a function pointer of type int (*)(void *, const char *, const char *)
    as well as a size_t. Some entries (namely the common entry for writing a
    report as well as several more of ffprobe's entries) used the pointer to
    void to store a pointer to functions of type int (*)(const char *) or
    type int (*)(const char *, const char *); nevertheless, when the functions
    are actually called in write_option (in cmdutils.c), it is done via a
    pointer of the first type.
    
    There are two things wrong here:
    1. Pointer to void can be converted to any pointer to incomplete or
    object type and back; but they are nevertheless not completely generic
    pointers: There is no provision in the C standard that guarantees their
    convertibility with function pointers. C90 lacks a generic function
    pointer, C99 made every function pointer a generic function pointer and
    still disallows the convertibility with void *.
    2. The signature of the called function differs from the signature
    of the pointed-to type. This is undefined behaviour in C99 (given that
    C90 lacks a way to convert function pointers at all, it doesn't say
    anything about such a situation). It only works because none of the
    functions this patch is about make any use of their parameters at all.
    
    Therefore this commit changes the type of the relevant functions
    to match the type used for the call and uses the union's function
    pointer to store it. This is legal even in C90.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Reviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
    Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
    f2d522f2
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...