advpack:files.c: Cast-qual warnings fix
Andrew Talbot
Andrew.Talbot at talbotville.com
Mon Aug 28 09:23:22 CDT 2006
Changelog:
advpack:files.c: Cast-qual warnings fix.
diff -urN a/dlls/advpack/files.c b/dlls/advpack/files.c
--- a/dlls/advpack/files.c 2006-05-23 13:47:31.000000000 +0100
+++ b/dlls/advpack/files.c 2006-08-28 15:05:08.000000000 +0100
@@ -116,7 +116,7 @@
LPCWSTR lpcszBaseName, DWORD dwFlags)
{
WCHAR szIniPath[MAX_PATH];
- LPWSTR szString = NULL;
+ LPCWSTR szString = NULL;
static const WCHAR szBackupEntry[] = {
'-','1',',','0',',','0',',','0',',','0',',','0',',','-','1',0
@@ -144,7 +144,7 @@
SetFileAttributesW(szIniPath, FILE_ATTRIBUTE_NORMAL);
if (dwFlags & AADBE_ADD_ENTRY)
- szString = (LPWSTR)szBackupEntry;
+ szString = szBackupEntry;
else if (dwFlags & AADBE_DEL_ENTRY)
szString = NULL;
@@ -249,9 +249,9 @@
DWORD dwFlags, DWORD dwReserved)
{
PSP_FILE_CALLBACK_W pFileCallback;
- LPWSTR szPath, szDestFilename;
+ LPCWSTR szPath;
WCHAR szRootPath[ROOT_LENGTH];
- DWORD dwLen, dwLastError;
+ DWORD dwLastError;
HSPFILEQ fileQueue;
PVOID pContext;
@@ -270,25 +270,13 @@
dwLastError = ERROR_SUCCESS;
lstrcpynW(szRootPath, lpszSourceDir, ROOT_LENGTH);
- szPath = (LPWSTR)lpszSourceDir + ROOT_LENGTH;
+ szPath = lpszSourceDir + ROOT_LENGTH;
- /* use lpszSourceFile as destination filename if lpszDestFile is NULL */
- if (lpszDestFile)
- {
- dwLen = lstrlenW(lpszDestFile);
- szDestFilename = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
- lstrcpyW(szDestFilename, lpszDestFile);
- }
- else
- {
- dwLen = lstrlenW(lpszSourceFile);
- szDestFilename = HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR));
- lstrcpyW(szDestFilename, lpszSourceFile);
- }
-
- /* add the file copy operation to the setup queue */
- if (!SetupQueueCopyW(fileQueue, szRootPath, szPath, lpszSourceFile, NULL,
- NULL, lpszDestDir, szDestFilename, dwFlags))
+ /* add the file copy operation to the setup queue -
+ * use lpszSourceFile as destination filename if lpszDestFile is NULL
+ */
+ if (!SetupQueueCopyW(fileQueue, szRootPath, szPath, lpszSourceFile, NULL, NULL,
+ lpszDestDir, lpszDestFile ? lpszDestFile: lpszSourceFile, dwFlags))
{
dwLastError = GetLastError();
goto done;
@@ -318,9 +306,7 @@
done:
SetupTermDefaultQueueCallback(pContext);
SetupCloseFileQueue(fileQueue);
-
- HeapFree(GetProcessHeap(), 0, szDestFilename);
-
+
return HRESULT_FROM_WIN32(dwLastError);
}
@@ -547,10 +533,15 @@
static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
{
DWORD dwLen;
- char *first = (char *)FileList;
- char *last = (char *)FileList + strlen(FileList) - 1;
- LPSTR szConvertedList, temp;
-
+ LPSTR buf, first, last, temp;
+
+ dwLen = strlen(FileList) + 2; /* room for double-null termination */
+ buf = HeapAlloc(GetProcessHeap(), 0, dwLen);
+ lstrcpyA(buf, FileList);
+
+ first = buf;
+ last = buf + dwLen - 3;
+
/* any number of these chars before the list is OK */
while (first < last && (*first == ' ' || *first == '\t' || *first == ':'))
first++;
@@ -562,21 +553,17 @@
if (first == last)
return NULL;
- dwLen = last - first + 3; /* room for double-null termination */
- szConvertedList = HeapAlloc(GetProcessHeap(), 0, dwLen);
- lstrcpynA(szConvertedList, first, dwLen - 1);
-
- szConvertedList[dwLen - 1] = '\0';
- szConvertedList[dwLen] = '\0';
+ *(last + 1) = '\0';
+ *(last + 2) = '\0';
/* empty list */
- if (!lstrlenA(szConvertedList))
+ if (!lstrlenA(first))
return NULL;
-
+
*dwNumFiles = 1;
/* convert the colons to double-null termination */
- temp = szConvertedList;
+ temp = first;
while (*temp)
{
if (*temp == ':')
@@ -588,7 +575,9 @@
temp++;
}
- return szConvertedList;
+ memmove(buf, first, last - first + 3);
+
+ return buf;
}
static void free_file_node(struct ExtractFileList *pNode)
More information about the wine-patches
mailing list