Alex Henrie : ntdll: Increase maximum number of autodetected COM/ LPT ports to 256.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Dec 25 11:19:21 CST 2015


Module: wine
Branch: master
Commit: 65942760c4e7816c5345a8a451ab4511c0426874
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=65942760c4e7816c5345a8a451ab4511c0426874

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Wed Dec 23 21:58:43 2015 -0700

ntdll: Increase maximum number of autodetected COM/LPT ports to 256.

Windows autodetects up to 256 serial ports and 256 parallel ports per
system.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/directory.c | 40 ++++++++++++++--------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 23ebf48..f3c6aa2 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -331,28 +331,19 @@ static char *get_default_com_device( int num )
 {
     char *ret = NULL;
 
-    if (!num || num > 9) return ret;
+    if (num < 1 || num > 256) return NULL;
 #ifdef linux
-    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/ttyS0") );
-    if (ret)
-    {
-        strcpy( ret, "/dev/ttyS0" );
-        ret[strlen(ret) - 1] = '0' + num - 1;
-    }
+    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/ttyS256") );
+    if (!ret) return NULL;
+    sprintf( ret, "/dev/ttyS%d", num - 1 );
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuau0") );
-    if (ret)
-    {
-        strcpy( ret, "/dev/cuau0" );
-        ret[strlen(ret) - 1] = '0' + num - 1;
-    }
+    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuau256") );
+    if (!ret) return NULL;
+    sprintf( ret, "/dev/cuau%d", num - 1 );
 #elif defined(__DragonFly__)
-    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuaa0") );
-    if (ret)
-    {
-        strcpy( ret, "/dev/cuaa0" );
-        ret[strlen(ret) - 1] = '0' + num - 1;
-    }
+    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/cuaa256") );
+    if (!ret) return NULL;
+    sprintf( ret, "/dev/cuaa%d", num - 1 );
 #else
     FIXME( "no known default for device com%d\n", num );
 #endif
@@ -369,14 +360,11 @@ static char *get_default_lpt_device( int num )
 {
     char *ret = NULL;
 
-    if (!num || num > 9) return ret;
+    if (num < 1 || num > 256) return NULL;
 #ifdef linux
-    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/lp0") );
-    if (ret)
-    {
-        strcpy( ret, "/dev/lp0" );
-        ret[strlen(ret) - 1] = '0' + num - 1;
-    }
+    ret = RtlAllocateHeap( GetProcessHeap(), 0, sizeof("/dev/lp256") );
+    if (!ret) return NULL;
+    sprintf( ret, "/dev/lp%d", num - 1 );
 #else
     FIXME( "no known default for device lpt%d\n", num );
 #endif




More information about the wine-cvs mailing list