Fix annoying COMM16 bug

Andreas Mohr andi at rhlx01.fht-esslingen.de
Sun Jan 9 08:22:57 CST 2005


Hi all,

someone mistakenly wrote (or kept unchanged during an async comm handling
rewrite??) the COMM16 read/write completion functions (called by ReadFileEx/
WriteFileEx) to check for NT status codes instead of the win error codes
which they're actually getting.

Note that both the ERROR_OPERATION_ABORTED and NO_ERROR codes should be
correct translations of the former NT status codes, since my uncle has a PBX
config program that had win error 0x3e3 (995, ERROR_OPERATION_ABORTED) turn up
in the read completion function (and of course it acted up, since due to the
wrong status code check it set an error there when in fact the comm abort was a
normal, successful operation).

The Auerswald PBX config program still doesn't fully communicate properly,
but it is working a bit better now.

Andreas Mohr

Index: dlls/user/comm16.c
===================================================================
RCS file: /home/wine/wine/dlls/user/comm16.c,v
retrieving revision 1.25
diff -u -r1.25 comm16.c
--- dlls/user/comm16.c	7 Jan 2005 15:40:09 -0000	1.25
+++ dlls/user/comm16.c	9 Jan 2005 14:12:30 -0000
@@ -60,7 +60,6 @@
 #include <errno.h>
 #include <ctype.h>
 
-#include "ntstatus.h"
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
@@ -178,9 +177,9 @@
 static void comm_waitread(struct DosDeviceStruct *ptr);
 static void comm_waitwrite(struct DosDeviceStruct *ptr);
 
-static VOID WINAPI COMM16_ReadComplete(DWORD status, DWORD len, LPOVERLAPPED ov)
+static VOID WINAPI COMM16_ReadComplete(DWORD dwErrorCode, DWORD len, LPOVERLAPPED ov)
 {
-	int prev ;
+	int prev;
 	WORD mask = 0;
 	int cid = GetCommPort_ov(ov,0);
 	struct DosDeviceStruct *ptr;
@@ -192,15 +191,15 @@
 	ptr = &COM[cid];
 
 	/* we get cancelled when CloseComm is called */
-	if (status==STATUS_CANCELLED)
+	if (dwErrorCode==ERROR_OPERATION_ABORTED)
 	{
 		TRACE("Cancelled\n");
 		return;
 	}
 
 	/* read data from comm port */
-	if (status != STATUS_SUCCESS) {
-		ERR("async read failed %08lx\n",status);
+	if (dwErrorCode != NO_ERROR) {
+		ERR("async read failed, error %ld\n",dwErrorCode);
 		COM[cid].commerror = CE_RXOVER;
 		return;
 	}
@@ -265,7 +264,7 @@
 	return count;
 }
 
-static VOID WINAPI COMM16_WriteComplete(DWORD status, DWORD len, LPOVERLAPPED ov)
+static VOID WINAPI COMM16_WriteComplete(DWORD dwErrorCode, DWORD len, LPOVERLAPPED ov)
 {
 	int prev, bleft;
 	WORD mask = 0;
@@ -279,8 +278,8 @@
 	ptr = &COM[cid];
 
 	/* read data from comm port */
-	if (status != STATUS_SUCCESS) {
-		ERR("async write failed\n");
+	if (dwErrorCode != NO_ERROR) {
+		ERR("async write failed, error %ld\n",dwErrorCode);
 		COM[cid].commerror = CE_RXOVER;
 		return;
 	}



More information about the wine-patches mailing list