From 7e72e7799b503b27ecd3827f269b0c58d9723894 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Mon, 6 Feb 2017 08:41:32 +0100 Subject: [PATCH] GlobalShortcut_win.cpp: Fix MinGW compilation warnings GlobalShortcut_win.h: In constructor 'GlobalShortcutWin::GlobalShortcutWin()': GlobalShortcut_win.h:77:7: warning: 'GlobalShortcutWin::nxboxinput' will be initialized after [-Wreorder] int nxboxinput; ^~~~~~~~~~ GlobalShortcut_win.h:61:16: warning: 'unsigned int GlobalShortcutWin::uiHardwareDevices' [-Wreorder] unsigned int uiHardwareDevices; ^~~~~~~~~~~~~~~~~ GlobalShortcut_win.cpp:44:1: warning: when initialized here [-Wreorder] GlobalShortcutWin::GlobalShortcutWin() ^~~~~~~~~~~~~~~~~ GlobalShortcut_win.cpp: In member function 'virtual void GlobalShortcutWin::run()': GlobalShortcut_win.cpp:85:85: warning: passing NULL to non-pointer argument 3 of 'LONG RegOpenKeyExA(HKEY, LPCSTR, DWORD, REGSAM, PHKEY)' [-Wconversion-null] if (RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\Desktop", NULL, KEY_READ, &key) == ERROR_SUCCESS) { ^ GlobalShortcut_win.cpp:88:85: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'DWORD {aka long unsigned int}' [-Wformat=] qWarning("GlobalShortcutWin: Found LowLevelHooksTimeout with value = 0x%x", value); ^ GlobalShortcut_win.cpp:92:129: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'LONG {aka long int}' [-Wformat=] qWarning("GlobalShortcutWin: Error looking up LowLevelHooksTimeout. (Error: 0x%x, Type: 0x%x, Value: 0x%x)", err, type, value); ^ GlobalShortcut_win.cpp:92:129: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=] GlobalShortcut_win.cpp:92:129: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=] GlobalShortcut_win.cpp: In static member function 'static BOOL GlobalShortcutWin::EnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE, LPVOID)': GlobalShortcut_win.cpp:378:28: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=] qPrintable(name)); ^ GlobalShortcut_win.cpp: In static member function 'static BOOL GlobalShortcutWin::EnumDevicesCB(LPCDIDEVICEINSTANCE, LPVOID)': GlobalShortcut_win.cpp:463:29: warning: format '%x' expects argument of type 'unsigned int', but argument 8 has type 'DWORD {aka long unsigned int}' [-Wformat=] pdidi->dwDevType); ^ GlobalShortcut_win.cpp:529:51: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'DWORD {aka long unsigned int}' [-Wformat=] qPrintable(id->vguidproduct.toString())); ^ --- src/mumble/GlobalShortcut_win.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp index a2fc8acf9..ece1ce44d 100644 --- a/src/mumble/GlobalShortcut_win.cpp +++ b/src/mumble/GlobalShortcut_win.cpp @@ -45,6 +45,7 @@ GlobalShortcutWin::GlobalShortcutWin() : pDI(NULL) , hhMouse(NULL) , hhKeyboard(NULL) + , uiHardwareDevices(0) #ifdef USE_GKEY , gkey(NULL) #endif @@ -52,8 +53,7 @@ GlobalShortcutWin::GlobalShortcutWin() , xboxinput(NULL) , nxboxinput(0) #endif - , uiHardwareDevices(0) { - +{ // Hidden setting to disable hooking bHook = g.qs->value(QLatin1String("winhooks"), true).toBool(); @@ -82,14 +82,14 @@ void GlobalShortcutWin::run() { DWORD type = 0; DWORD value = 0; DWORD len = sizeof(DWORD); - if (RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\Desktop", NULL, KEY_READ, &key) == ERROR_SUCCESS) { + if (RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ, &key) == ERROR_SUCCESS) { LONG err = RegQueryValueExA(key, "LowLevelHooksTimeout", NULL, &type, reinterpret_cast(&value), &len); if (err == ERROR_SUCCESS && type == REG_DWORD) { - qWarning("GlobalShortcutWin: Found LowLevelHooksTimeout with value = 0x%x", value); + qWarning("GlobalShortcutWin: Found LowLevelHooksTimeout with value = 0x%lx", static_cast(value)); } else if (err == ERROR_FILE_NOT_FOUND) { qWarning("GlobalShortcutWin: No LowLevelHooksTimeout registry key found."); } else { - qWarning("GlobalShortcutWin: Error looking up LowLevelHooksTimeout. (Error: 0x%x, Type: 0x%x, Value: 0x%x)", err, type, value); + qWarning("GlobalShortcutWin: Error looking up LowLevelHooksTimeout. (Error: 0x%lx, Type: 0x%lx, Value: 0x%lx)", static_cast(err), static_cast(type), static_cast(value)); } } @@ -371,10 +371,10 @@ BOOL CALLBACK GlobalShortcutWin::EnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINST id->qhNames[lpddoi->dwType] = name; if (g.s.bDirectInputVerboseLogging) { - qWarning("GlobalShortcutWin: EnumObjects: device %s %s object 0x%.8x %s", + qWarning("GlobalShortcutWin: EnumObjects: device %s %s object 0x%.8lx %s", qPrintable(QUuid(id->guid).toString()), qPrintable(id->name), - lpddoi->dwType, + static_cast(lpddoi->dwType), qPrintable(name)); } @@ -454,13 +454,13 @@ BOOL GlobalShortcutWin::EnumDevicesCB(LPCDIDEVICEINSTANCE pdidi, LPVOID pContext // blacklist, we need a more structured aproach. { if (id->vendor_id == 0x262A) { - qWarning("GlobalShortcutWin: rejected blacklisted device %s (GUID: %s, PGUID: %s, VID: 0x%.4x, PID: 0x%.4x, TYPE: 0x%.8x)", + qWarning("GlobalShortcutWin: rejected blacklisted device %s (GUID: %s, PGUID: %s, VID: 0x%.4x, PID: 0x%.4x, TYPE: 0x%.8lx)", qPrintable(id->name), qPrintable(id->vguid.toString()), qPrintable(id->vguidproduct.toString()), id->vendor_id, id->product_id, - pdidi->dwDevType); + static_cast(pdidi->dwDevType)); delete id; return DIENUM_CONTINUE; } @@ -520,12 +520,12 @@ BOOL GlobalShortcutWin::EnumDevicesCB(LPCDIDEVICEINSTANCE pdidi, LPVOID pContext if (FAILED(hr = id->pDID->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph))) qFatal("GlobalShortcutWin: SetProperty: %lx", hr); - qWarning("Adding device %s %s %s:%d type 0x%.8x guid product %s", + qWarning("Adding device %s %s %s:%d type 0x%.8lx guid product %s", qPrintable(QUuid(id->guid).toString()), qPrintable(name), qPrintable(sname), id->qhNames.count(), - pdidi->dwDevType, + static_cast(pdidi->dwDevType), qPrintable(id->vguidproduct.toString())); cbgsw->qhInputDevices[id->guid] = id;