[FFmpeg-devel] [PATCH] Use intptr_t
Ramiro Polla
ramiro.polla
Mon Mar 16 19:15:17 CET 2009
Hi,
2009/3/16 M?ns Rullg?rd <mans at mansr.com>:
> Ramiro Polla <ramiro.polla at gmail.com> writes:
>> 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.
Patch updated.
>> ? ? ?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.
Is (intptr_t) or (int) safe?
Ramiro Polla
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intptr_t.diff
Type: text/x-patch
Size: 4191 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090316/f77b0ce9/attachment.bin>
More information about the ffmpeg-devel
mailing list