rasapi32: return an error for invalid paramaters

Juan Lang juan.lang at gmail.com
Wed Jun 25 12:12:11 CDT 2008

Hi Austin, at the risk of getting flamed for discussing elementary C
here I'll give some feedback.

+static void test_rasenum(void)
+BOOL result;

Indentation and whitespace are a little funny here.


This is a little confused.  You've named a type (LPRASDEVINFO) but not
a variable.  The naive fix would be to something like the following:


This at least declares a variable (pRDV) of type LPRASDEVINFO.  It
might even compile, but it'll certainly crash:  The first parameter to
RasEnumDeviceA is a pointer, and a pointer must point to a valid
memory location, or have the special value NULL.

What you most likely want is something like this:

rasDevInfo.dwSize = sizeof(rasDevInfo);

+	result = RasEnumDevicesA(LPRASDEVINFOA, NULL, LPDWORD lpcDevices);

Here you're passing a type (LPRASDEVINFOA) as the first parameter.  If
you use what I gave above, you'd want &rasDevInfo to be the first
parameter instead.

The third parameter is also bogus.  You want to declare a DWORD
cDevices, and pass &cDevices instead.

+	result = RasEnumDevicesA(NULL, LPDWORD lpcb, LPDWORD lpcDevices);

Again you've got something that won't compile.  You need to declare a
DWORD cb, and pass &cb as the second parameter.  For good measure you
should probably initialize it to something (maybe 0?), since MSDN says
the second parameter is an in/out parameter.

Feel free to whip up another one for review.

More information about the wine-devel mailing list