[FFmpeg-devel] uint32_t arg and %X conversion specifier

Måns Rullgård mans
Thu Jan 15 19:39:25 CET 2009


Marc Mason <mpeg.blue at free.fr> writes:

> Michael Niedermayer wrote:
>> Marc Mason wrote:
>>> M?ns Rullg?rd wrote:
>>>> Marc Mason wrote:
>>>>
>>>>> I see two ways to fix the following (very minor) warning.
>>>>>
>>>>> avidec.c:428: warning: format '%X' expects type 'unsigned int', but
>>>>> argument 4 has type 'uint32_t'
>>>>>
>>>>> 1) cast the arg to unsigned long
>>>>> http://home.att.net/~jackklein/c/inttypes.html#long
>>>>> drawback : on platforms where long are 64-bits wide, this will push 4
>>>>> useless ( == 0 ) octets
>>>>
>>>> One could cast to unsigned int too.
>>>
>>> I don't think so.
>>>
>>> Consider a platform where
>>> sizeof(unsigned int)  = 16 bits
>> isn't allowed by POSIX and our code wouldn't work there anyway.
>
> I was not aware of that. Thanks for bringing it to my attention.
>
> http://www.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
>
> {UINT_MAX}
>     Maximum value for an object of type unsigned.
>     [CX] Minimum Acceptable Value: 4 294 967 295
>
> Thus the first patch has a variant.

Both explicitly sized types and casts are things that should only be
used when necessary.  Does the offending variable really need to be
uint32_t in the first place?

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list