GKey.cpp: Fix MinGW compilation warnings #2812

Merged
merged 1 commit into from Feb 5, 2017

Projects

None yet

2 participants

@davidebeatrici
Member
GKey.cpp:89:95: warning: passing NULL to non-pointer argument 3 of 'LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)' [-Wconversion-null]
  if (RegOpenKeyEx(GKEY_LOGITECH_DLL_REG_HKEY, GKEY_LOGITECH_DLL_REG_PATH, NULL, KEY_READ, &key) == ERROR_SUCCESS) {
                                                                                               ^
GKey.cpp:93:111: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
    qWarning("GKeyLibrary: Found ServerBinary with libLocation = \"%s\", len = %d", qPrintable(qsLocation), len);
                                                                                                               ^
GKey.cpp:96:108: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'LONG {aka long int}' [-Wformat=]
    qWarning("GKeyLibrary: Error looking up ServerBinary (Error: 0x%x, Type: 0x%x, len: %d)", err, type, len);
                                                                                                            ^
GKey.cpp:96:108: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
GKey.cpp:96:108: warning: format '%d' expects argument of type 'int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=]
@davidebeatrici davidebeatrici added the build label Feb 4, 2017
@davidebeatrici
Member
GKey.cpp:96:109: warning: unknown conversion type character ',' in format [-Wformat=]
    qWarning("GKeyLibrary: Error looking up ServerBinary (Error: 0x%l, Type: 0x%l, len: %lu)", err, type, len);
                                                                                                             ^
GKey.cpp:96:109: warning: unknown conversion type character ',' in format [-Wformat=]
GKey.cpp:96:109: warning: too many arguments for format [-Wformat-extra-args]
@davidebeatrici davidebeatrici reopened this Feb 4, 2017
src/mumble/GKey.cpp
LONG err = RegQueryValueEx(key, L"", NULL, &type, reinterpret_cast<LPBYTE>(wcLocation), &len);
if (err == ERROR_SUCCESS && type == REG_SZ) {
QString qsLocation = QString::fromUtf16(reinterpret_cast<ushort *>(wcLocation), len / 2);
- qWarning("GKeyLibrary: Found ServerBinary with libLocation = \"%s\", len = %d", qPrintable(qsLocation), len);
+ qWarning("GKeyLibrary: Found ServerBinary with libLocation = \"%s\", len = %lu", qPrintable(qsLocation), len);
@mkrautz
mkrautz Feb 5, 2017 Member

Please use static_cast<unsigned long>(len) when using len as a parameter to qWarning, since DWORD isn't === unsigned long.

src/mumble/GKey.cpp
alternatives << qsLocation;
} else {
- qWarning("GKeyLibrary: Error looking up ServerBinary (Error: 0x%x, Type: 0x%x, len: %d)", err, type, len);
+ qWarning("GKeyLibrary: Error looking up ServerBinary (Error: 0x%l, Type: 0x%l, len: %lu)", err, type, len);
@mkrautz
mkrautz Feb 5, 2017 Member

Please use

0x%lx instead of %x
and for all params, use static_cast<unsigned long>

@davidebeatrici davidebeatrici GKey.cpp: Fix MinGW compilation warnings
GKey.cpp:89:95: warning: passing NULL to non-pointer argument 3 of 'LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)' [-Wconversion-null]
  if (RegOpenKeyEx(GKEY_LOGITECH_DLL_REG_HKEY, GKEY_LOGITECH_DLL_REG_PATH, NULL, KEY_READ, &key) == ERROR_SUCCESS) {
                                                                                               ^
GKey.cpp:93:111: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
    qWarning("GKeyLibrary: Found ServerBinary with libLocation = \"%s\", len = %d", qPrintable(qsLocation), len);
                                                                                                               ^
GKey.cpp:96:108: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'LONG {aka long int}' [-Wformat=]
    qWarning("GKeyLibrary: Error looking up ServerBinary (Error: 0x%x, Type: 0x%x, len: %d)", err, type, len);
                                                                                                            ^
GKey.cpp:96:108: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
GKey.cpp:96:108: warning: format '%d' expects argument of type 'int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=]
e8c8220
@mkrautz
mkrautz approved these changes Feb 5, 2017 View changes
@mkrautz mkrautz merged commit cef2324 into mumble-voip:master Feb 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment