Mercurial > mplayer.hg
comparison vidix/sysdep/pci_linux.c @ 35218:03021b062140
Fix more places that incorrectly assume that 0
can never be a valid file descriptor.
author | reimar |
---|---|
date | Wed, 31 Oct 2012 19:50:11 +0000 |
parents | c45cbe0d8ce1 |
children |
comparison
equal
deleted
inserted
replaced
35217:c45cbe0d8ce1 | 35218:03021b062140 |
---|---|
41 #include "config.h" | 41 #include "config.h" |
42 | 42 |
43 #ifdef CONFIG_DHAHELPER | 43 #ifdef CONFIG_DHAHELPER |
44 #include <fcntl.h> | 44 #include <fcntl.h> |
45 int dhahelper_initialized = 0; | 45 int dhahelper_initialized = 0; |
46 int dhahelper_fd = 0; | 46 int dhahelper_fd = -1; |
47 #endif | 47 #endif |
48 | 48 |
49 #ifdef CONFIG_SVGAHELPER | 49 #ifdef CONFIG_SVGAHELPER |
50 #include <svgalib_helper.h> | 50 #include <svgalib_helper.h> |
51 #include <linux/ioctl.h> | 51 #include <linux/ioctl.h> |
53 #ifndef SVGALIB_HELPER_IOC_MAGIC | 53 #ifndef SVGALIB_HELPER_IOC_MAGIC |
54 /* svgalib 1.9.18+ compatibility ::atmos */ | 54 /* svgalib 1.9.18+ compatibility ::atmos */ |
55 #define SVGALIB_HELPER_IOCGPCIINL SVGAHELPER_PCIINL | 55 #define SVGALIB_HELPER_IOCGPCIINL SVGAHELPER_PCIINL |
56 #endif | 56 #endif |
57 int svgahelper_initialized = 0; | 57 int svgahelper_initialized = 0; |
58 int svgahelper_fd = 0; | 58 int svgahelper_fd = -1; |
59 | 59 |
60 static int pci_config_type(void) | 60 static int pci_config_type(void) |
61 { | 61 { |
62 return 1; | 62 return 1; |
63 } | 63 } |
90 | 90 |
91 static inline int enable_os_io(void) | 91 static inline int enable_os_io(void) |
92 { | 92 { |
93 #ifdef CONFIG_SVGAHELPER | 93 #ifdef CONFIG_SVGAHELPER |
94 svgahelper_fd = open(DEV_SVGA, O_RDWR); | 94 svgahelper_fd = open(DEV_SVGA, O_RDWR); |
95 if (svgahelper_fd > 0) | 95 if (svgahelper_fd != -1) |
96 { | 96 { |
97 svgahelper_initialized = 1; | 97 svgahelper_initialized = 1; |
98 return 0; | 98 return 0; |
99 } | 99 } |
100 svgahelper_initialized = -1; | 100 svgahelper_initialized = -1; |
101 #endif | 101 #endif |
102 | 102 |
103 #ifdef CONFIG_DHAHELPER | 103 #ifdef CONFIG_DHAHELPER |
104 dhahelper_fd = open("/dev/dhahelper", O_RDWR); | 104 dhahelper_fd = open("/dev/dhahelper", O_RDWR); |
105 if (dhahelper_fd > 0) | 105 if (dhahelper_fd != -1) |
106 { | 106 { |
107 dhahelper_initialized = 1; | 107 dhahelper_initialized = 1; |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 dhahelper_initialized = -1; | 110 dhahelper_initialized = -1; |
203 else if (pread(fd, &retval, 4, cmd) == 4) { | 203 else if (pread(fd, &retval, 4, cmd) == 4) { |
204 retval = le2me_32(retval); | 204 retval = le2me_32(retval); |
205 } else { | 205 } else { |
206 retval = 0; | 206 retval = 0; |
207 } | 207 } |
208 if (fd > 0) { | 208 if (fd != -1) { |
209 close(fd); | 209 close(fd); |
210 } | 210 } |
211 return retval; | 211 return retval; |
212 } | 212 } |
213 #endif /* defined(CONFIG_PCI_LINUX_PROC) */ | 213 #endif /* defined(CONFIG_PCI_LINUX_PROC) */ |