[vlc-devel] [PATCH] libmp4: fix argument for formatting

Rémi Denis-Courmont remi at remlab.net
Fri Mar 27 17:15:03 CET 2020

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

Rémi Denis-Courmont

More information about the vlc-devel mailing list