[libdvdcss-devel] [PATCH 3/7] device: Check for errors from close() also on Windows

Diego Biurrun diego at biurrun.de
Sun Nov 16 20:37:10 CET 2014


---
 src/device.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/device.c b/src/device.c
index 51b41be..46ab121 100644
--- a/src/device.c
+++ b/src/device.c
@@ -392,27 +392,25 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
 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;
 }
-- 
2.1.0



More information about the libdvdcss-devel mailing list