[Lldb-commits] [lldb] [lldb] [Windows] Silence format string warnings (PR #150886)
Martin Storsjö via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 28 01:34:27 PDT 2025
https://github.com/mstorsjo updated https://github.com/llvm/llvm-project/pull/150886
>From 4ee1be1011c4579325b513f3e7459ac8d0c32a5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Mon, 28 Jul 2025 09:27:36 +0300
Subject: [PATCH 1/2] [lldb] [Windows] Silence format string warnings
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.
---
lldb/source/Host/windows/MainLoopWindows.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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;
}
>From 8133c3667f894dc03df25e2ac911d37e4523e6a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Mon, 28 Jul 2025 11:34:06 +0300
Subject: [PATCH 2/2] Use %ld for DWORD, rather than a static cast
---
lldb/source/Host/windows/MainLoopWindows.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp
index f7f65a82f726f..c0b10797e506a 100644
--- a/lldb/source/Host/windows/MainLoopWindows.cpp
+++ b/lldb/source/Host/windows/MainLoopWindows.cpp
@@ -235,8 +235,8 @@ MainLoopWindows::RegisterReadObject(const IOObjectSP &object_sp,
} else {
DWORD file_type = GetFileType(waitable_handle);
if (file_type != FILE_TYPE_PIPE) {
- error = Status::FromErrorStringWithFormat("Unsupported file type %d",
- static_cast<int>(file_type));
+ error = Status::FromErrorStringWithFormat("Unsupported file type %ld",
+ file_type);
return nullptr;
}
More information about the lldb-commits
mailing list