[libdvdcss-devel] device: Check for errors from close() also on Windows
Diego Biurrun
git at videolan.org
Sun Nov 16 21:37:49 CET 2014
libdvdcss | branch: master | Diego Biurrun <diego at biurrun.de> | Fri Nov 14 21:05:42 2014 +0100| [aababbe6e30298c460a5837831c0e81ffbd3c2f7] | committer: Diego Biurrun
device: Check for errors from close() also on Windows
> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=aababbe6e30298c460a5837831c0e81ffbd3c2f7
---
src/device.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/device.c b/src/device.c
index bcd54e2..7384f86 100644
--- a/src/device.c
+++ b/src/device.c
@@ -410,27 +410,25 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
int dvdcss_close_device ( dvdcss_t dvdcss )
{
#if defined( WIN32 )
- if( dvdcss->b_file )
- {
- close( dvdcss->i_fd );
- }
- else
- {
- CloseHandle( (HANDLE) dvdcss->i_fd );
- }
-
/* Free readv temporary buffer */
free( dvdcss->p_readv_buffer );
dvdcss->p_readv_buffer = NULL;
dvdcss->i_readv_buf_size = 0;
-#else
- int i_ret = close( dvdcss->i_fd );
- if( i_ret < 0 )
+
+ if( !dvdcss->b_file )
{
- print_error( dvdcss, "Failed to close fd, data loss possible." );
- return i_ret;
+ CloseHandle( (HANDLE) dvdcss->i_fd );
}
+ else
#endif
+ {
+ int i_ret = close( dvdcss->i_fd );
+ if( i_ret < 0 )
+ {
+ print_error( dvdcss, "Failed to close fd, data loss possible." );
+ return i_ret;
+ }
+ }
return 0;
}
More information about the libdvdcss-devel
mailing list