[libdvdcss-devel] device: Simplify construction of native device name in win2k_open()

[email protected] (Alexander Strasser) Sun, 2 Nov 2014 21:02:06 +0100 (CET)
Newsgroups gmane.comp.video.videolan.libdvdcss,gmane.comp.video.videolan.libdvdcss.devel
Message-ID <[email protected]>
libdvdcss | branch: master | Alexander Strasser <[email protected]> | Sat Nov  1 22:43:02 2014 +0100| [9718193ae6aabcc8ac7c551e117ca18703d56b71] | committer: Diego Biurrun

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

Avoid error handling where it is not needed.

Signed-off-by: Alexander Strasser <[email protected]>
Signed-off-by: Diego Biurrun <[email protected]>

> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=9718193ae6aabcc8ac7c551e117ca18703d56b71
---

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

diff --git a/src/device.c b/src/device.c
index fdc1e15..965fb15 100644
--- a/src/device.c
+++ b/src/device.c
@@ -468,11 +468,8 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
 #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 @@ static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
 
     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 ) */
 

_______________________________________________
libdvdcss-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvdcss-devel