-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb] [Windows] Silence format string warnings #150886
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
Conversation
This fixes the following build warnings in a mingw environment:
../../lldb/source/Host/windows/MainLoopWindows.cpp:226:50: warning: format specifies type 'int' but the argument has type 'IOObject::WaitableHandle' (aka 'void *') [-Wformat]
226 | "File descriptor %d already monitored.", waitable_handle);
| ~~ ^~~~~~~~~~~~~~~
../../lldb/source/Host/windows/MainLoopWindows.cpp:239:49: warning: format specifies type 'int' but the argument has type 'DWORD' (aka 'unsigned long') [-Wformat]
238 | error = Status::FromErrorStringWithFormat("Unsupported file type %d",
| ~~
| %lu
239 | file_type);
| ^~~~~~~~~
2 warnings generated.
|
@llvm/pr-subscribers-lldb Author: Martin Storsjö (mstorsjo) ChangesThis fixes the following build warnings in a mingw environment: Full diff: https://github.com/llvm/llvm-project/pull/150886.diff 1 Files Affected:
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
index c1a018238432d..f7f65a82f726f 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -223,7 +223,7 @@ MainLoopWindows::RegisterReadObject(const IOObjectSP &object_sp,
if (m_read_fds.find(waitable_handle) != m_read_fds.end()) {
error = Status::FromErrorStringWithFormat(
- "File descriptor %d already monitored.", waitable_handle);
+ "File descriptor %p already monitored.", waitable_handle);
return nullptr;
}
@@ -236,7 +236,7 @@ MainLoopWindows::RegisterReadObject(const IOObjectSP &object_sp,
DWORD file_type = GetFileType(waitable_handle);
if (file_type != FILE_TYPE_PIPE) {
error = Status::FromErrorStringWithFormat("Unsupported file type %d",
- file_type);
+ static_cast<int>(file_type));
return nullptr;
}
|
|
Should you use I assume since they didn't note it, it's the same size on x86 and x86_64. |
|
Oh but is there a Mingw detail here that means the cast is better? |
No, mingw should conform quite closely regarding such details. I just didn't feel like assuming such details about the type of DWORD, but you're right, and it should be fine to do that instead. Will update. |
|
Tested that this still silences the warnings, on both 32 and 64 bit. |
labath
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though personally, I'd use FromErrorStringWithFormatv and let it deduce the format.
|
/cherry-pick 98ec927 |
|
/pull-request #150919 |
This fixes the following build warnings in a mingw environment:
../../lldb/source/Host/windows/MainLoopWindows.cpp:226:50: warning:
format specifies type 'int' but the argument has type
'IOObject::WaitableHandle' (aka 'void *') [-Wformat]
226 | "File descriptor %d already monitored.", waitable_handle);
| ~~ ^~~~~~~~~~~~~~~
../../lldb/source/Host/windows/MainLoopWindows.cpp:239:49: warning:
format specifies type 'int' but the argument has type 'DWORD' (aka
'unsigned long') [-Wformat]
238 | error = Status::FromErrorStringWithFormat("Unsupported file type
%d",
| ~~
| %lu
239 | file_type);
| ^~~~~~~~~
2 warnings generated.
(cherry picked from commit 98ec927)
This fixes the following build warnings in a mingw environment: