Author: tfaber Date: Sun Nov 6 13:33:29 2011 New Revision: 54314
URL: http://svn.reactos.org/svn/reactos?rev=54314&view=rev Log: [ADVAPI32][SERVICES] - Remove unnecessary casts, fix some const-ness, fix a DPRINT, some spacing
Modified: trunk/reactos/base/system/services/config.c trunk/reactos/base/system/services/database.c trunk/reactos/base/system/services/rpcserver.c trunk/reactos/base/system/services/services.c trunk/reactos/base/system/services/services.h trunk/reactos/dll/win32/advapi32/service/scm.c
Modified: trunk/reactos/base/system/services/config.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/config... ============================================================================== --- trunk/reactos/base/system/services/config.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/config.c [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -94,7 +94,7 @@
DWORD ScmWriteDependencies(HKEY hServiceKey, - LPWSTR lpDependencies, + LPCWSTR lpDependencies, DWORD dwDependenciesLength) { DWORD dwError = ERROR_SUCCESS; @@ -103,7 +103,7 @@ DWORD dwLength; LPWSTR lpGroupDeps; LPWSTR lpServiceDeps; - LPWSTR lpSrc; + LPCWSTR lpSrc; LPWSTR lpDst;
if (*lpDependencies == 0)
Modified: trunk/reactos/base/system/services/database.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/databa... ============================================================================== --- trunk/reactos/base/system/services/database.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -191,9 +191,9 @@ if (pServiceImage == NULL) { /* Create a new service image */ - pServiceImage = (PSERVICE_IMAGE)HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(SERVICE_IMAGE) + ((wcslen(ImagePath.Buffer) + 1) * sizeof(WCHAR))); + pServiceImage = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(SERVICE_IMAGE) + ((wcslen(ImagePath.Buffer) + 1) * sizeof(WCHAR))); if (pServiceImage == NULL) { dwError = ERROR_NOT_ENOUGH_MEMORY; @@ -366,7 +366,7 @@ DPRINT("Service: '%S'\n", lpServiceName);
/* Allocate service entry */ - lpService = (SERVICE*)HeapAlloc(GetProcessHeap(), + lpService = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SERVICE) + ((wcslen(lpServiceName) + 1) * sizeof(WCHAR))); if (lpService == NULL) @@ -584,15 +584,17 @@ { /* Find the maximum subkey length so that we can allocate a buffer */ dwRet = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, - &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL); + &dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL); if (!dwRet) { dwMaxSubkeyLen++; - if (dwMaxSubkeyLen > sizeof(szNameBuf)/sizeof(WCHAR)) + if (dwMaxSubkeyLen > sizeof(szNameBuf) / sizeof(WCHAR)) + { /* Name too big: alloc a buffer for it */ - lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(WCHAR)); - - if(!lpszName) + lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen * sizeof(WCHAR)); + } + + if (!lpszName) dwRet = ERROR_NOT_ENOUGH_MEMORY; else { @@ -835,7 +837,7 @@
BufferLength = sizeof(OBJECT_DIRECTORY_INFORMATION) + 2 * MAX_PATH * sizeof(WCHAR); - DirInfo = (OBJECT_DIRECTORY_INFORMATION*) HeapAlloc(GetProcessHeap(), + DirInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BufferLength);
@@ -942,9 +944,9 @@ PacketSize = sizeof(SCM_CONTROL_PACKET); PacketSize += (wcslen(Service->lpServiceName) + 1) * sizeof(WCHAR);
- ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - PacketSize); + ControlPacket = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + PacketSize); if (ControlPacket == NULL) { LeaveCriticalSection(&ControlServiceCriticalSection); @@ -1171,9 +1173,9 @@ }
/* Allocate a control packet */ - ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - PacketSize); + ControlPacket = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + PacketSize); if (ControlPacket == NULL) return ERROR_NOT_ENOUGH_MEMORY;
Modified: trunk/reactos/base/system/services/rpcserver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcser... ============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -144,16 +144,16 @@
if (_wcsicmp(lpDatabaseName, SERVICES_FAILED_DATABASEW) == 0) { - DPRINT("Database %S, does not exist\n",lpDatabaseName); + DPRINT("Database %S, does not exist\n", lpDatabaseName); return ERROR_DATABASE_DOES_NOT_EXIST; } else if (_wcsicmp(lpDatabaseName, SERVICES_ACTIVE_DATABASEW) != 0) { - DPRINT("Invalid Database name %S.\n",lpDatabaseName); + DPRINT("Invalid Database name %S.\n", lpDatabaseName); return ERROR_INVALID_NAME; }
- Ptr = (MANAGER_HANDLE*) HeapAlloc(GetProcessHeap(), + Ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MANAGER_HANDLE) + (wcslen(lpDatabaseName) + 1) * sizeof(WCHAR)); if (Ptr == NULL) @@ -175,7 +175,7 @@ { PSERVICE_HANDLE Ptr;
- Ptr = (SERVICE_HANDLE*) HeapAlloc(GetProcessHeap(), + Ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SERVICE_HANDLE)); if (Ptr == NULL) @@ -629,7 +629,7 @@ &pcbBytesNeeded, &dwServicesReturned);
- /* if pcbBytesNeeded returned a value then there are services running that are dependent on this service*/ + /* if pcbBytesNeeded returned a value then there are services running that are dependent on this service */ if (pcbBytesNeeded) { DPRINT("Deletion failed due to running dependencies.\n"); @@ -1400,9 +1400,9 @@ (wcslen(lpDisplayName) + 1) * sizeof(WCHAR));
/* Update the display name */ - lpDisplayNameW = (LPWSTR)HeapAlloc(GetProcessHeap(), - 0, - (wcslen(lpDisplayName) + 1) * sizeof(WCHAR)); + lpDisplayNameW = HeapAlloc(GetProcessHeap(), + 0, + (wcslen(lpDisplayName) + 1) * sizeof(WCHAR)); if (lpDisplayNameW == NULL) { dwError = ERROR_NOT_ENOUGH_MEMORY; @@ -2083,7 +2083,7 @@ *lpDisplayName != 0 && _wcsicmp(lpService->lpDisplayName, lpDisplayName) != 0) { - lpService->lpDisplayName = (WCHAR*) HeapAlloc(GetProcessHeap(), 0, + lpService->lpDisplayName = HeapAlloc(GetProcessHeap(), 0, (wcslen(lpDisplayName) + 1) * sizeof(WCHAR)); if (lpService->lpDisplayName == NULL) { @@ -2212,7 +2212,7 @@ if (lpDependencies != NULL && *lpDependencies != 0) { dwError = ScmWriteDependencies(hServiceKey, - (LPWSTR)lpDependencies, + (LPCWSTR)lpDependencies, dwDependSize); if (dwError != ERROR_SUCCESS) goto done; @@ -3519,7 +3519,7 @@ DWORD dwDependenciesLength = 0; DWORD dwLength; int len; - LPSTR lpStr; + LPCSTR lpStr;
if (lpServiceName) { @@ -3571,7 +3571,7 @@
if (lpDependencies) { - lpStr = (LPSTR)lpDependencies; + lpStr = (LPCSTR)lpDependencies; while (*lpStr) { dwLength = strlen(lpStr) + 1; @@ -3586,7 +3586,7 @@ SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto cleanup; } - MultiByteToWideChar(CP_ACP, 0, (LPSTR)lpDependencies, dwDependenciesLength, lpDependenciesW, dwDependenciesLength); + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)lpDependencies, dwDependenciesLength, lpDependenciesW, dwDependenciesLength); }
if (lpServiceStartName)
Modified: trunk/reactos/base/system/services/services.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servic... ============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -379,7 +379,7 @@ ExitThread(0); }
- DPRINT("SERVICES: created start event with handle %x.\n", hScmStartEvent); + DPRINT("SERVICES: created start event with handle %p.\n", hScmStartEvent);
// ScmInitThreadManager();
Modified: trunk/reactos/base/system/services/services.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servic... ============================================================================== --- trunk/reactos/base/system/services/services.h [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -88,7 +88,7 @@ PHKEY phKey);
DWORD ScmWriteDependencies(HKEY hServiceKey, - LPWSTR lpDependencies, + LPCWSTR lpDependencies, DWORD dwDependenciesLength);
DWORD ScmMarkServiceForDelete(PSERVICE pService);
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/... ============================================================================== --- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Sun Nov 6 13:33:29 2011 @@ -288,14 +288,14 @@ DWORD dwError; DWORD dwDependenciesLength = 0; DWORD dwLength; - LPSTR lpStr; + LPCSTR lpStr;
TRACE("ChangeServiceConfigA() called\n");
/* Calculate the Dependencies length*/ if (lpDependencies != NULL) { - lpStr = (LPSTR)lpDependencies; + lpStr = lpDependencies; while (*lpStr) { dwLength = strlen(lpStr) + 1; @@ -362,14 +362,14 @@ DWORD dwError; DWORD dwDependenciesLength = 0; DWORD dwLength; - LPWSTR lpStr; + LPCWSTR lpStr;
TRACE("ChangeServiceConfigW() called\n");
/* Calculate the Dependencies length*/ if (lpDependencies != NULL) { - lpStr = (LPWSTR)lpDependencies; + lpStr = lpDependencies; while (*lpStr) { dwLength = wcslen(lpStr) + 1; @@ -540,7 +540,7 @@ DWORD dwDependenciesLength = 0; DWORD dwError; DWORD dwLength; - LPSTR lpStr; + LPCSTR lpStr;
TRACE("CreateServiceA() called\n"); TRACE("%p %s %s\n", hSCManager, @@ -552,10 +552,10 @@ return NULL; }
- /* Calculate the Dependencies length*/ + /* Calculate the Dependencies length */ if (lpDependencies != NULL) { - lpStr = (LPSTR)lpDependencies; + lpStr = lpDependencies; while (*lpStr) { dwLength = strlen(lpStr) + 1; @@ -628,7 +628,7 @@ DWORD dwDependenciesLength = 0; DWORD dwError; DWORD dwLength; - LPWSTR lpStr; + LPCWSTR lpStr;
TRACE("CreateServiceW() called\n"); TRACE("%p %S %S\n", hSCManager, @@ -640,10 +640,10 @@ return NULL; }
- /* Calculate the Dependencies length*/ + /* Calculate the Dependencies length */ if (lpDependencies != NULL) { - lpStr = (LPWSTR)lpDependencies; + lpStr = lpDependencies; while (*lpStr) { dwLength = wcslen(lpStr) + 1;