On Wed, Jun 25, 2008 at 12:12 PM, Juan Lang <[EMAIL PROTECTED]> wrote: > Hi Austin, at the risk of getting flamed for discussing elementary C > here I'll give some feedback.
Appreciate the help. I don't have any C experience, so this testcase was hacked together by looking at a few other testcases in the testsuite + msdn. > + LPRASDEVINFO = sizeof(RASDEVINFO); > > 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: > > LPRASDEVINFO pRDV = sizeof(RASDEVINFO); > > 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: > RASDEVINFOA rasDevInfo; > > 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. > --Juan > I made these changes, but still not compiling: [EMAIL PROTECTED]:~/wine-git/dlls/rasapi32/tests$ make crosstest i586-mingw32msvc-gcc -c -I. -I. -I../../../include -I../../../include -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -g -O2 -o rasapi.cross.o rasapi.c rasapi.c:1: warning: -fPIC ignored for target (all code is position independent) rasapi.c: In function `test_rasenum': rasapi.c:36: error: request for member `dwSize' in something not a structure or union rasapi.c:37: warning: ISO C90 forbids mixed declarations and code rasapi.c:40: warning: passing arg 1 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:40: warning: passing arg 3 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:41: warning: implicit declaration of function `ok' rasapi.c:44: warning: passing arg 2 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:44: warning: passing arg 3 of `RasEnumDevicesA' from incompatible pointer type rasapi.c: At top level: rasapi.c:51: warning: return type defaults to `int' make: *** [rasapi.cross.o] Error 1 I've tried assigning those args different types, but none seem to be working (int,float,etc.). I've found a C guide that I'm going through now, but don't know how long that'll take. If someone has a few minutes to kill and a penchant for guiding C programming, please contact me off list...I don't want to flood -devel with elementary C questions. Or if someone wants to take my patch and fix it up, have at it. I'm just trying to get a bug fixed ;-). -Austin
/* * Unit test suite for rasapi functions * * Copyright 2008 Austin English * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include <stdio.h> #include <stdarg.h> #include <windef.h> #include <winbase.h> #include <wine/debug.h> #include <windows.h> #include "ras.h" #include "raserror.h" static void test_rasenum(void) { BOOL result; int rasDevInfo; rasDevInfo.dwSize = sizeof(rasDevInfo); int *cDevices = 0; int *cb = 0; result = RasEnumDevicesA(&rasDevInfo, NULL, &cDevices); ok(!result && (GetLastError() == ERROR_INVALID_PARAMETER), "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); result = RasEnumDevicesA(NULL, &cb, &cDevices); ok(!result && (GetLastError() == ERROR_INVALID_PARAMETER), "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError()); } START_TEST(rasapi) { test_rasenum(); }