setupapi/tests: Fix string format warnings.

This commit is contained in:
Vincent Povirk 2008-12-04 21:49:40 -06:00 committed by Alexandre Julliard
parent 445588ba10
commit 022a8439e0
3 changed files with 44 additions and 66 deletions

View File

@ -320,30 +320,23 @@ static void test_SetupDiOpenClassRegKeyExA(void)
trace("failed to open classes key\n"); trace("failed to open classes key\n");
} }
static void append_str(char **str, const char *data)
{
sprintf(*str, data);
*str += strlen(*str);
}
static void create_inf_file(LPCSTR filename) static void create_inf_file(LPCSTR filename)
{ {
char data[1024];
char *ptr = data;
DWORD dwNumberOfBytesWritten; DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL, HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
append_str(&ptr, "[Version]\n"); static const char data[] =
append_str(&ptr, "Signature=\"$Chicago$\"\n"); "[Version]\n"
append_str(&ptr, "Class=Bogus\n"); "Signature=\"$Chicago$\"\n"
append_str(&ptr, "ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}\n"); "Class=Bogus\n"
append_str(&ptr, "[ClassInstall32]\n"); "ClassGUID={6a55b5a4-3f65-11db-b704-0011955c2bdb}\n"
append_str(&ptr, "AddReg=BogusClass.NT.AddReg\n"); "[ClassInstall32]\n"
append_str(&ptr, "[BogusClass.NT.AddReg]\n"); "AddReg=BogusClass.NT.AddReg\n"
append_str(&ptr, "HKR,,,,\"Wine test devices\"\n"); "[BogusClass.NT.AddReg]\n"
"HKR,,,,\"Wine test devices\"\n";
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf); CloseHandle(hf);
} }

View File

@ -47,29 +47,22 @@ static BOOL (WINAPI *pSetupGetFileCompressionInfoExA)(PCSTR, PSTR, DWORD, PDWORD
static BOOL (WINAPI *pSetupCopyOEMInfA)(PCSTR, PCSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR *); static BOOL (WINAPI *pSetupCopyOEMInfA)(PCSTR, PCSTR, DWORD, DWORD, PSTR, DWORD, PDWORD, PSTR *);
static BOOL (WINAPI *pSetupQueryInfOriginalFileInformationA)(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_A); static BOOL (WINAPI *pSetupQueryInfOriginalFileInformationA)(PSP_INF_INFORMATION, UINT, PSP_ALTPLATFORM_INFO, PSP_ORIGINAL_FILE_INFO_A);
static void append_str(char **str, const char *data)
{
sprintf(*str, data);
*str += strlen(*str);
}
static void create_inf_file(LPCSTR filename) static void create_inf_file(LPCSTR filename)
{ {
char data[1024];
char *ptr = data;
DWORD dwNumberOfBytesWritten; DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL, HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
append_str(&ptr, "[Version]\n"); static const char data[] =
append_str(&ptr, "Signature=\"$Chicago$\"\n"); "[Version]\n"
append_str(&ptr, "AdvancedINF=2.5\n"); "Signature=\"$Chicago$\"\n"
append_str(&ptr, "[DefaultInstall]\n"); "AdvancedINF=2.5\n"
append_str(&ptr, "RegisterOCXs=RegisterOCXsSection\n"); "[DefaultInstall]\n"
append_str(&ptr, "[RegisterOCXsSection]\n"); "RegisterOCXs=RegisterOCXsSection\n"
append_str(&ptr, "%%11%%\\ole32.dll\n"); "[RegisterOCXsSection]\n"
"%%11%%\\ole32.dll\n";
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf); CloseHandle(hf);
} }

View File

@ -43,56 +43,48 @@ static void get_directories(void)
WIN_DIR[len-1] = 0; WIN_DIR[len-1] = 0;
} }
static void append_str(char **str, const char *data)
{
sprintf(*str, data);
*str += strlen(*str);
}
static void create_inf_file(LPSTR filename) static void create_inf_file(LPSTR filename)
{ {
char data[1024];
char *ptr = data;
DWORD dwNumberOfBytesWritten; DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL, HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
append_str(&ptr, "[Version]\n"); static const char data[] =
append_str(&ptr, "Signature=\"$Chicago$\"\n"); "[Version]\n"
append_str(&ptr, "AdvancedINF=2.5\n"); "Signature=\"$Chicago$\"\n"
append_str(&ptr, "[SourceDisksNames]\n"); "AdvancedINF=2.5\n"
append_str(&ptr, "2 = %%SrcDiskName%%, LANCOM\\LANtools\\lanconf.cab\n"); "[SourceDisksNames]\n"
append_str(&ptr, "[SourceDisksFiles]\n"); "2 = %SrcDiskName%, LANCOM\\LANtools\\lanconf.cab\n"
append_str(&ptr, "lanconf.exe = 2\n"); "[SourceDisksFiles]\n"
append_str(&ptr, "[DestinationDirs]\n"); "lanconf.exe = 2\n"
append_str(&ptr, "DefaultDestDir = 24, %%DefaultDest%%\n"); "[DestinationDirs]\n"
append_str(&ptr, "[Strings]\n"); "DefaultDestDir = 24, %DefaultDest%\n"
append_str(&ptr, "LangDir = english\n"); "[Strings]\n"
append_str(&ptr, "DefaultDest = LANCOM\n"); "LangDir = english\n"
append_str(&ptr, "SrcDiskName = \"LANCOM Software CD\"\n"); "DefaultDest = LANCOM\n"
"SrcDiskName = \"LANCOM Software CD\"\n";
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf); CloseHandle(hf);
} }
static void create_inf_file2(LPSTR filename) static void create_inf_file2(LPSTR filename)
{ {
char data[1024];
char *ptr = data;
DWORD dwNumberOfBytesWritten; DWORD dwNumberOfBytesWritten;
HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL, HANDLE hf = CreateFile(filename, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
append_str(&ptr, "[SourceFileInfo]\n"); static const char data[] =
append_str(&ptr, "sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"); "[SourceFileInfo]\n"
append_str(&ptr, "sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"); "sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"
append_str(&ptr, "sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"); "sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"
append_str(&ptr, "sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"); "sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"
append_str(&ptr, "sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"); "sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"
append_str(&ptr, "sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"); "sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"
append_str(&ptr, "sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n"); "sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"
"sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n";
WriteFile(hf, data, ptr - data, &dwNumberOfBytesWritten, NULL); WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
CloseHandle(hf); CloseHandle(hf);
} }