[FFmpeg-devel] [PATCH] Use intptr_t

Måns Rullgård mans
Mon Mar 16 18:53:54 CET 2009


Ramiro Polla <ramiro.polla at gmail.com> writes:

> Hi,
>
> This silences some warnings for mingw-w64.
>
> Ramiro Polla
>
> diff --git a/libavformat/file.c b/libavformat/file.c
> index bec991a..b11737a 100644
> --- a/libavformat/file.c
> +++ b/libavformat/file.c
> @@ -36,7 +36,7 @@
>  static int file_open(URLContext *h, const char *filename, int flags)
>  {
>      int access;
> -    int fd;
> +    intptr_t fd;

I wouldn't do that.  The correct type for a file descriptor is 'int',
nothing else.

>      av_strstart(filename, "file:", &filename);
>  
> @@ -59,32 +59,32 @@ static int file_open(URLContext *h, const char *filename, int flags)
>  
>  static int file_read(URLContext *h, unsigned char *buf, int size)
>  {
> -    int fd = (int) h->priv_data;
> +    int fd = (intptr_t) h->priv_data;
>      return read(fd, buf, size);
>  }

This should be safe since intptr_t is guaranteed to preserve all bits
from the pointer.  If pointers are smaller than int, the code was
already broken.


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




More information about the ffmpeg-devel mailing list