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

Måns Rullgård mans
Thu Jan 15 15:32:35 CET 2009


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

> Hello,
>
> 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.

> 2) use the appropriate macro for the conversion specifier
> http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html
> drawback : C99 specific ??

We already use those in many places.  The avidec maintainer can decide
what to do.

> Index: avidec.c
> ===================================================================
> --- avidec.c	(revision 16615)
> +++ avidec.c	(working copy)
> @@ -425,7 +425,7 @@
>                  codec_type = CODEC_TYPE_DATA;
>                  break;
>              default:
> -                av_log(s, AV_LOG_ERROR, "unknown stream type %X\n", tag1);
> +                av_log(s, AV_LOG_ERROR, "unknown stream type %lX\n", (unsigned long)tag1);
>                  goto fail;
>              }
>              ast->frame_offset= ast->cum_len;
> Index: avidec.c
> ===================================================================
> --- avidec.c	(revision 16615)
> +++ avidec.c	(working copy)
> @@ -425,7 +425,7 @@
>                  codec_type = CODEC_TYPE_DATA;
>                  break;
>              default:
> -                av_log(s, AV_LOG_ERROR, "unknown stream type %X\n", tag1);
> +                av_log(s, AV_LOG_ERROR, "unknown stream type %"PRIX32"\n", tag1);
>                  goto fail;
>              }
>              ast->frame_offset= ast->cum_len;

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




More information about the ffmpeg-devel mailing list