Browse code

Remove size_t cast in setting s->priv_data directly to the (integer) file descriptor returned by open(). This removes some dubious doublecasts such as priv_data = (void *) (size_t) some_integer, and is always safe on systems we care about because sizeof(int)<=sizeof(void*). See comments from Mans and Michael in "[RFC] rtsp.c EOF support" thread.

Originally committed as revision 17768 to svn://svn.ffmpeg.org/ffmpeg/trunk

Ronald S. Bultje authored on 2009/03/03 22:57:09
Showing 1 changed files
... ...
@@ -53,32 +53,32 @@ static int file_open(URLContext *h, const char *filename, int flags)
53 53
     fd = open(filename, access, 0666);
54 54
     if (fd < 0)
55 55
         return AVERROR(ENOENT);
56
-    h->priv_data = (void *)(size_t)fd;
56
+    h->priv_data = (void *) fd;
57 57
     return 0;
58 58
 }
59 59
 
60 60
 static int file_read(URLContext *h, unsigned char *buf, int size)
61 61
 {
62
-    int fd = (size_t)h->priv_data;
62
+    int fd = (int) h->priv_data;
63 63
     return read(fd, buf, size);
64 64
 }
65 65
 
66 66
 static int file_write(URLContext *h, unsigned char *buf, int size)
67 67
 {
68
-    int fd = (size_t)h->priv_data;
68
+    int fd = (int) h->priv_data;
69 69
     return write(fd, buf, size);
70 70
 }
71 71
 
72 72
 /* XXX: use llseek */
73 73
 static int64_t file_seek(URLContext *h, int64_t pos, int whence)
74 74
 {
75
-    int fd = (size_t)h->priv_data;
75
+    int fd = (int) h->priv_data;
76 76
     return lseek(fd, pos, whence);
77 77
 }
78 78
 
79 79
 static int file_close(URLContext *h)
80 80
 {
81
-    int fd = (size_t)h->priv_data;
81
+    int fd = (int) h->priv_data;
82 82
     return close(fd);
83 83
 }
84 84
 
... ...
@@ -110,7 +110,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
110 110
 #if HAVE_SETMODE
111 111
     setmode(fd, O_BINARY);
112 112
 #endif
113
-    h->priv_data = (void *)(size_t)fd;
113
+    h->priv_data = (void *) fd;
114 114
     h->is_streamed = 1;
115 115
     return 0;
116 116
 }