shithub: libdvdcss

Download patch

ref: 9718193ae6aabcc8ac7c551e117ca18703d56b71
parent: 2697472efc58b75d0a66a4d605215a6689301213
author: Alexander Strasser <eclipse7@gmx.net>
date: Sat Nov 1 18:43:02 EDT 2014

device: Simplify construction of native device name in win2k_open()

Avoid error handling where it is not needed.

Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Diego Biurrun <diego@biurrun.de>

--- a/src/device.c
+++ b/src/device.c
@@ -468,11 +468,8 @@
 #if defined( WIN32 )
 static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
 {
-    char psz_dvd[7];
-    if( snprintf( psz_dvd, sizeof(psz_dvd), "\\\\.\\%c:", psz_device[0] ) < 0)
-    {
-        goto error;
-    }
+    char psz_dvd[7] = "\\\\.\\\0:";
+    psz_dvd[4] = psz_device[0];
 
     /* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
      * _and_ write access to the device (so we can make SCSI Pass Through
@@ -496,16 +493,13 @@
 
     if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
     {
-        goto error;
+        print_error( dvdcss, "failed opening device" );
+        return -1;
     }
 
     dvdcss->i_pos = 0;
 
     return 0;
-
-error:
-    print_error( dvdcss, "failed opening device" );
-    return -1;
 }
 #endif /* defined( WIN32 ) */