public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix throw_winerror_with_name build error on x86-64 Cygwin
@ 2024-02-23 16:55 Pedro Alves
  2024-02-23 17:05 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Pedro Alves @ 2024-02-23 16:55 UTC (permalink / raw)
  To: gdb-patches

The GDB build currently fails on x86-64 Cygwin, with:

 src/gdbsupport/errors.cc: In function ‘void throw_winerror_with_name(const char*, ULONGEST)’:
 src/gdbsupport/errors.cc:152:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ULONGEST’ {aka ‘long unsigned int’} [-Werror=format=]
   152 |   error (_("%s (error %d): %s"), string, err, strwinerror (err));
       |            ^

Fix this by adding a cast.  While at it, the error codes are really a
DWORD that results from a GetLastError() call, so I think unsigned is
more appropriate.  That is also what strwinerror already does:

    sprintf (buf, "unknown win32 error (%u)", (unsigned) error);

The cast is necessary on MinGW GDB as well, where ULONGEST is unsigned
long long, but for some reason, I don't get a warning there.

Change-Id: I3f5faa779765fd8021abf58bb5f68d556b309d17
---
 gdbsupport/errors.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdbsupport/errors.cc b/gdbsupport/errors.cc
index 8ac3ed0da79..cccdc5cafb2 100644
--- a/gdbsupport/errors.cc
+++ b/gdbsupport/errors.cc
@@ -149,7 +149,7 @@ strwinerror (ULONGEST error)
 void
 throw_winerror_with_name (const char *string, ULONGEST err)
 {
-  error (_("%s (error %d): %s"), string, err, strwinerror (err));
+  error (_("%s (error %u): %s"), string, (unsigned) err, strwinerror (err));
 }
 
 #endif /* USE_WIN32API */

base-commit: e433bca4847acd34b6178a392335ed10060639ec
-- 
2.43.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-23 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 16:55 [PATCH] Fix throw_winerror_with_name build error on x86-64 Cygwin Pedro Alves
2024-02-23 17:05 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).