Commit bb1fc335 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

include/msvcrt: Add attribute((format)) to printf and scanf -like APIs.

Fix a bunch of warnings generated by this patch and the migration of GUID.Data1 to long in ae2693e2Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c47f3052
......@@ -657,7 +657,7 @@ HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid)
*/
INT16 WINAPI StringFromGUID216(REFGUID id, char *str, INT16 cmax)
{
static const char format[] = "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}";
static const char format[] = "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}";
if (!id || cmax < CHARS_IN_GUID) return 0;
sprintf( str, format, id->Data1, id->Data2, id->Data3,
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
......
......@@ -40,7 +40,7 @@ static void CRYPT_guid2wstr( const GUID *guid, LPWSTR wstr )
{
char str[40];
sprintf(str, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
sprintf(str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
......
......@@ -59,7 +59,7 @@ static const NPI_MODULEID *ip_module_id( USHORT family )
DWORD WINAPI ConvertGuidToStringA( const GUID *guid, char *str, DWORD len )
{
if (len < CHARS_IN_GUID) return ERROR_INSUFFICIENT_BUFFER;
sprintf( str, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
sprintf( str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2],
guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
return ERROR_SUCCESS;
......
......@@ -1409,7 +1409,7 @@ static void testGetAdaptersInfo(void)
GetIfEntry( &row );
ConvertInterfaceIndexToLuid( ptr->Index, &luid );
ConvertInterfaceLuidToGuid( &luid, &guid );
sprintf( name, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
sprintf( name, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7] );
......@@ -1671,7 +1671,7 @@ static void test_GetAdaptersAddresses(void)
status = ConvertInterfaceLuidToGuid(&aa->Luid, &guid);
ok(!status, "got %u\n", status);
sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
sprintf(buf, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
......
......@@ -31,7 +31,7 @@ static const GUID GUID_wmp1 = {0x13a7995e,0x7d8f,0x45b4,{0x9c,0x77,0x81,0x92,0x6
static const char *guid_to_string(const GUID *guid)
{
static char buffer[50];
sprintf(buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
sprintf(buffer, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
......
......@@ -627,7 +627,7 @@ static HRESULT register_server(BOOL do_register)
for(i=0; i < ARRAY_SIZE(pse); i++) {
pse[i].pszValue = heap_alloc(39);
sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
sprintf(pse[i].pszValue, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
......
......@@ -832,7 +832,7 @@ static HRESULT reg_get_typelib_module(REFIID iid, WCHAR *module, DWORD len)
BOOL is_wow64;
HKEY ikey;
sprintf( interfacekey, "Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
sprintf( interfacekey, "Interface\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\Typelib",
iid->Data1, iid->Data2, iid->Data3,
iid->Data4[0], iid->Data4[1], iid->Data4[2], iid->Data4[3],
iid->Data4[4], iid->Data4[5], iid->Data4[6], iid->Data4[7]
......
......@@ -3660,7 +3660,7 @@ static BOOL TLB_GUIDFromString(const char *str, GUID *guid)
int i;
short s;
if(sscanf(str, "%x-%hx-%hx-%hx", &guid->Data1, &guid->Data2, &guid->Data3, &s) != 4) {
if(sscanf(str, "%lx-%hx-%hx-%hx", &guid->Data1, &guid->Data2, &guid->Data3, &s) != 4) {
FIXME("Can't parse guid %s\n", debugstr_guid(guid));
return FALSE;
}
......
......@@ -543,7 +543,7 @@ RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, RPC_CSTR* StringUuid)
if (!Uuid) Uuid = &uuid_nil;
sprintf( (char*)*StringUuid, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
sprintf( (char*)*StringUuid, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
Uuid->Data1, Uuid->Data2, Uuid->Data3,
Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
......@@ -566,7 +566,7 @@ RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR* StringUuid)
if (!Uuid) Uuid = &uuid_nil;
sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
sprintf(buf, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
Uuid->Data1, Uuid->Data2, Uuid->Data3,
Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
......
......@@ -200,7 +200,7 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LP
static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
{
char xriid[50];
sprintf( xriid, "CLSID\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
riid->Data1, riid->Data2, riid->Data3,
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
......
......@@ -247,7 +247,7 @@ void _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
{
if (szOut)
sprintf( szOut, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
sprintf( szOut, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
riid->Data1, riid->Data2, riid->Data3,
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
......
......@@ -61,7 +61,7 @@ BOOL trash_file( const WCHAR *path ) DECLSPEC_HIDDEN;
static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str)
{
return sprintf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
return sprintf(str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
......
......@@ -461,7 +461,7 @@ INT WINAPI SHStringFromGUIDA(REFGUID guid, LPSTR lpszDest, INT cchMax)
TRACE("(%s,%p,%d)\n", debugstr_guid(guid), lpszDest, cchMax);
sprintf(xguid, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
sprintf(xguid, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
......
......@@ -82,7 +82,7 @@ QueryPathOfRegTypeLib16(
TRACE("\n");
if (HIWORD(guid)) {
sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%x\\win16",
sprintf( typelibkey, "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%x\\win16",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
......
......@@ -1041,7 +1041,7 @@ static ULONG format_datetime( const WS_DATETIME *ptr, unsigned char *buf )
static ULONG format_guid( const GUID *ptr, unsigned char *buf )
{
static const char fmt[] = "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
static const char fmt[] = "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
return sprintf( (char *)buf, fmt, ptr->Data1, ptr->Data2, ptr->Data3,
ptr->Data4[0], ptr->Data4[1], ptr->Data4[2], ptr->Data4[3],
ptr->Data4[4], ptr->Data4[5], ptr->Data4[6], ptr->Data4[7] );
......@@ -1049,7 +1049,7 @@ static ULONG format_guid( const GUID *ptr, unsigned char *buf )
static ULONG format_urn( const GUID *ptr, unsigned char *buf )
{
static const char fmt[] = "urn:uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
static const char fmt[] = "urn:uuid:%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
return sprintf( (char *)buf, fmt, ptr->Data1, ptr->Data2, ptr->Data3,
ptr->Data4[0], ptr->Data4[1], ptr->Data4[2], ptr->Data4[3],
ptr->Data4[4], ptr->Data4[5], ptr->Data4[6], ptr->Data4[7] );
......
......@@ -417,7 +417,7 @@ static BOOL deliver_next_report(struct device_extension *ext, IRP *irp)
for (i = 0; i < report->length;)
{
char buffer[256], *buf = buffer;
buf += sprintf(buf, "%08x ", i);
buf += sprintf(buf, "%08lx ", i);
do { buf += sprintf(buf, " %02x", report->buffer[i]); }
while (++i % 16 && i < report->length);
TRACE("%s\n", buffer);
......@@ -1054,7 +1054,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
for (i = 0; i < packet->reportBufferLen;)
{
char buffer[256], *buf = buffer;
buf += sprintf(buf, "%08x ", i);
buf += sprintf(buf, "%08lx ", i);
do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); }
while (++i % 16 && i < packet->reportBufferLen);
TRACE("%s\n", buffer);
......@@ -1084,7 +1084,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
for (i = 0; i < packet->reportBufferLen;)
{
char buffer[256], *buf = buffer;
buf += sprintf(buf, "%08x ", i);
buf += sprintf(buf, "%08lx ", i);
do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); }
while (++i % 16 && i < packet->reportBufferLen);
TRACE("%s\n", buffer);
......@@ -1103,7 +1103,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
for (i = 0; i < packet->reportBufferLen;)
{
char buffer[256], *buf = buffer;
buf += sprintf(buf, "%08x ", i);
buf += sprintf(buf, "%08lx ", i);
do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); }
while (++i % 16 && i < packet->reportBufferLen);
TRACE("%s\n", buffer);
......@@ -1120,7 +1120,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
for (i = 0; i < packet->reportBufferLen;)
{
char buffer[256], *buf = buffer;
buf += sprintf(buf, "%08x ", i);
buf += sprintf(buf, "%08lx ", i);
do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); }
while (++i % 16 && i < packet->reportBufferLen);
TRACE("%s\n", buffer);
......
......@@ -334,4 +334,12 @@ typedef struct threadlocaleinfostruct {
#define _THREADLOCALEINFO
#endif
#if !defined(__WINE_USE_MSVCRT) || defined(__MINGW32__)
#define __WINE_CRT_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
#define __WINE_CRT_SCANF_ATTR(fmt,args) __attribute__((format (scanf,fmt,args)))
#else
#define __WINE_CRT_PRINTF_ATTR(fmt,args)
#define __WINE_CRT_SCANF_ATTR(fmt,args)
#endif
#endif /* __WINE_CORECRT_H */
......@@ -88,7 +88,7 @@ extern int _crtDbgFlag;
_ACRTIMP int __cdecl _CrtCheckMemory(void);
_ACRTIMP int WINAPIV _CrtDbgReport(int reportType, const char *filename, int linenumber,
const char *moduleName, const char *format, ...);
const char *moduleName, const char *format, ...) __WINE_CRT_PRINTF_ATTR(5, 6);
_ACRTIMP int __cdecl _CrtDumpMemoryLeaks(void);
_ACRTIMP int __cdecl _CrtSetBreakAlloc(int);
_ACRTIMP int __cdecl _CrtSetDbgFlag(int);
......
......@@ -865,7 +865,7 @@ static HMODULE load_com_dll(const char *name, char **path, char *filename)
if(!get_main_clsid(name, &clsid)) return NULL;
sprintf(keyname, "CLSID\\{%08x-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
sprintf(keyname, "CLSID\\{%08lx-%04x-%04x-%02x%2x-%02x%2x%02x%2x%02x%2x}\\InprocServer32",
clsid.Data1, clsid.Data2, clsid.Data3, clsid.Data4[0], clsid.Data4[1],
clsid.Data4[2], clsid.Data4[3], clsid.Data4[4], clsid.Data4[5],
clsid.Data4[6], clsid.Data4[7]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment