Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GKey.cpp: Fix MinGW compilation warnings #2812

Merged
merged 1 commit into from Feb 5, 2017

Conversation

@davidebeatrici
Copy link
Member

commented Feb 4, 2017

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

This comment has been minimized.

Copy link
Member Author

commented Feb 4, 2017

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]
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);

This comment has been minimized.

Copy link
@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.

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);

This comment has been minimized.

Copy link
@mkrautz

mkrautz Feb 5, 2017

Member

Please use

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

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=]

@davidebeatrici davidebeatrici force-pushed the davidebeatrici:GKey.cpp_fix-warnings branch from 63d75fb to e8c8220 Feb 5, 2017

@mkrautz
mkrautz approved these changes Feb 5, 2017

@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
Projects
None yet
2 participants
You can’t perform that action at this time.