I sent this to ros-dev about 3 months ago but nobody commited.
ChangeLog:
Correct return values. Fix suggested by w3seek.
Index: misc/comm.c
===================================================================
--- misc/comm.c (revision 16707)
+++ misc/comm.c (working copy)
@@ -834,7 +834,7 @@
CommConfigDialogA(LPCSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC)
{
PWCHAR NameW;
- BOOL result;
+ DWORD result;
/* don't use the static thread buffer so operations in serialui
don't overwrite the string */
@@ -858,9 +858,9 @@
STDCALL
CommConfigDialogW(LPCWSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC)
{
- BOOL (STDCALL *drvCommDlgW)(LPCWSTR, HWND, LPCOMMCONFIG);
+ DWORD (STDCALL *drvCommDlgW)(LPCWSTR, HWND, LPCOMMCONFIG);
HMODULE hSerialuiDll;
- BOOL result;
+ DWORD result;
//FIXME: Get dll name from registry. (setupapi needed)
if(!(hSerialuiDll = LoadLibraryW(L"serialui.dll")))
@@ -869,7 +869,8 @@
return FALSE;
}
- drvCommDlgW = GetProcAddress(hSerialuiDll, "drvCommConfigDialogW");
+ drvCommDlgW = (DWORD (STDCALL *)(LPCWSTR, HWND, LPCOMMCONFIG))
+ GetProcAddress(hSerialuiDll, "drvCommConfigDialogW");
if(!drvCommDlgW)
{
@@ -879,8 +880,10 @@
}
result = drvCommDlgW(lpszName, hWnd, lpCC);
+ SetLastError(result);
FreeLibrary(hSerialuiDll);
- return result;
+
+ return (result == ERROR_SUCCESS ? TRUE : FALSE);
}
Index: serialui.h
===================================================================
--- serialui.h (revision 16707)
+++ serialui.h (working copy)
@@ -11,8 +11,7 @@
#include "resource.h"
#define UNIMPLEMENTED \
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \
- return FALSE;
+ return ERROR_CALL_NOT_IMPLEMENTED ;
#define DEFAULT_BAUD_INDEX 6
#define DEFAULT_BYTESIZE_INDEX 3
@@ -45,27 +44,27 @@
*
************************************/
-BOOL WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
+DWORD WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig);
-BOOL WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
+DWORD WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig);
-BOOL WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
+DWORD WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize);
-BOOL WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
+DWORD WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize);
-BOOL WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
+DWORD WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize);
-BOOL WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
+DWORD WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize);
Index: serialui.c
===================================================================
--- serialui.c (revision 16707)
+++ serialui.c (working copy)
@@ -98,7 +98,7 @@
/*
* @implemented
*/
-BOOL WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
+DWORD WINAPI drvCommConfigDialogW(LPCWSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig)
{
@@ -106,7 +106,7 @@
if(!lpszDevice || !lpCommConfig)
{
- return FALSE;
+ return ERROR_INVALID_PARAMETER;
}
DialogInfo.lpszDevice = lpszDevice;
@@ -119,7 +119,7 @@
/*
* @implemented
*/
-BOOL WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
+DWORD WINAPI drvCommConfigDialogA(LPCSTR lpszDevice,
HWND hWnd,
LPCOMMCONFIG lpCommConfig)
{
@@ -136,13 +136,13 @@
return result;
}
else
- return FALSE;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
/*
* @unimplemented
*/
-BOOL WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
+DWORD WINAPI drvSetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize)
{
@@ -152,7 +152,7 @@
/*
* @unimplemented
*/
-BOOL WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
+DWORD WINAPI drvSetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
DWORD dwSize)
{
@@ -162,7 +162,7 @@
/*
* @unimplemented
*/
-BOOL WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
+DWORD WINAPI drvGetDefaultCommConfigW(LPCWSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize)
{
@@ -172,7 +172,7 @@
/*
* @unimplemented
*/
-BOOL WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
+DWORD WINAPI drvGetDefaultCommConfigA(LPCSTR lpszDevice,
LPCOMMCONFIG lpCommConfig,
LPDWORD lpdwSize)
{
@@ -231,7 +231,7 @@
/* Initialize baud rate combo */
if(!(hBox = GetDlgItem(hDlg, IDC_BAUDRATE)))
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, ERROR_CANCELLED);
for(i = 0; Bauds[i]; i++)
{
@@ -246,7 +246,7 @@
/* Initialize byte size combo */
if(!(hBox = GetDlgItem(hDlg, IDC_BYTESIZE)))
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, ERROR_CANCELLED);
for(i = 0; ByteSizes[i]; i++)
{
@@ -261,7 +261,7 @@
/* Initialize parity combo */
if(!(hBox = GetDlgItem(hDlg, IDC_PARITY)))
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, ERROR_CANCELLED);
for(i = 0; Parities[i].StrId; i++)
{
@@ -278,7 +278,7 @@
/* Initialize stop bits combo */
if(!(hBox = GetDlgItem(hDlg, IDC_STOPBITS)))
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, ERROR_CANCELLED);
for(i = 0; StopBits[i].StrId; i++)
{
@@ -295,7 +295,7 @@
/* Initialize flow control combo */
if(!(hBox = GetDlgItem(hDlg, IDC_FLOW)))
- EndDialog(hDlg, 0);
+ EndDialog(hDlg, ERROR_CANCELLED);
if(LoadStringW(hDllInstance, IDS_FC_NO, wstr, sizeof(wstr) / sizeof(wstr[0])))
{
@@ -337,11 +337,11 @@
switch(wParam)
{
case IDC_CANCELBTN:
- EndDialog(hDlg, FALSE);
+ EndDialog(hDlg, ERROR_CANCELLED);
break;
case IDC_OKBTN:
OkButton(hDlg);
- EndDialog(hDlg, TRUE);
+ EndDialog(hDlg, ERROR_SUCCESS);
break;
}
return TRUE;
@@ -349,11 +349,11 @@
case WM_CLOSE:
{
- EndDialog(hDlg, FALSE);
+ EndDialog(hDlg, ERROR_CANCELLED);
return TRUE;
} /* WM_CLOSE */
- default:
+ default:
return FALSE;
}