[vlc-devel] [PATCH] libmp4: fix argument for formatting
ajanni at videolabs.io
Fri Mar 27 17:24:23 CET 2020
On Fri, Mar 27, 2020 at 06:15:03PM +0200, Rémi Denis-Courmont wrote:
> Le perjantaina 27. maaliskuuta 2020, 18.07.58 EET Alexandre Janniaux a écrit :
> > On Fri, Mar 27, 2020 at 05:55:00PM +0200, Rémi Denis-Courmont wrote:
> > > Le perjantaina 27. maaliskuuta 2020, 17.45.16 EET Alexandre Janniaux a
> écrit :
> > > > i_profile_level is uint8_t but the bitwise operation is promoting it to
> > > > an int,
> > >
> > > That's *irrelevant*. Expression is promoted to integer rank regardless of
> > > the shift because it is a variadic argument.
> > >
> > > The current code is just fine. PRIu8 *expects* a promoted uint8_t value.
> > This is not what clang says with a uint8_t foo:
> I don't know what clang says, but this is what clang actually does as well as
> what the specification says that clang must do.
> If you don't believe me, you can try to read a uint8_t from va_arg() and see
> what happens, e.g.:
> :16: warning: ‘unsigned char’ is promoted to ‘int’ when passed through ‘...’
> va_arg(ap, unsigned char);
> :16: note: (so you should pass ‘int’ not ‘unsigned char’ to ‘va_arg’)
> :16: note: if this code is reached, the program will abort
I know that va_arg promotes to int, but it has nothing to do
with the warning itself which is to ensure the format matches
the value given from the calling site. AFAIK the specification
doesn't specify the warnings.
More information about the vlc-devel