From: Mark Geisert <mark@maxrnd.com>
To: cygwin-patches@cygwin.com
Subject: [PATCH] Cygwin: fix format warnings in profiler.cc
Date: Wed, 21 Jul 2021 01:00:40 -0700 [thread overview]
Message-ID: <20210721080040.55316-1-mark@maxrnd.com> (raw)
In-Reply-To: <5acddcda-7fa9-e854-911c-27af2f13a22c@dronecode.org.uk>
Use new typedef to normalize pids for printing on both 32- and 64-bit Cygwin.
---
winsup/utils/profiler.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/winsup/utils/profiler.cc b/winsup/utils/profiler.cc
index d1a01c3a2..152bf1cca 100644
--- a/winsup/utils/profiler.cc
+++ b/winsup/utils/profiler.cc
@@ -29,6 +29,7 @@
#include "cygwin/version.h"
#include "cygtls_padsize.h"
#include "gcc_seh.h"
+typedef unsigned long ulong;
typedef unsigned short ushort;
typedef uint16_t u_int16_t; // Non-standard sized type needed by ancient gmon.h
#define NO_GLOBALS_H
@@ -312,10 +313,10 @@ dump_profile_data (child *c)
if (s->name)
{
WCHAR *name = 1 + wcsrchr (s->name, L'\\');
- sprintf (filename, "%s.%u.%ls", prefix, c->pid, name);
+ sprintf (filename, "%s.%lu.%ls", prefix, (ulong) c->pid, name);
}
else
- sprintf (filename, "%s.%u", prefix, c->pid);
+ sprintf (filename, "%s.%lu", prefix, (ulong) c->pid);
fd = open (filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY);
if (fd < 0)
@@ -804,9 +805,9 @@ cygwin_pid (DWORD winpid)
cygpid = (DWORD) cygwin_internal (CW_WINPID_TO_CYGWIN_PID, winpid);
if (cygpid >= max_cygpid)
- snprintf (buf, sizeof buf, "%u", winpid);
+ snprintf (buf, sizeof buf, "%lu", (ulong) winpid);
else
- snprintf (buf, sizeof buf, "%u (pid: %u)", winpid, cygpid);
+ snprintf (buf, sizeof buf, "%lu (pid: %lu)", (ulong) winpid, (ulong) cygpid);
return buf;
}
--
2.32.0
next prev parent reply other threads:[~2021-07-21 8:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-16 4:49 [PATCH 1/3] Cygwin: New tool: profiler Mark Geisert
2021-07-16 4:49 ` [PATCH 2/3] Cygwin: New tool: gmondump Mark Geisert
2021-07-16 4:49 ` [PATCH 3/3] Cygwin: updates to wire in profiler, gmondump Mark Geisert
2021-07-19 10:04 ` [PATCH 1/3] Cygwin: New tool: profiler Corinna Vinschen
2021-07-19 14:23 ` Jon Turney
2021-07-19 15:43 ` Jon Turney
2021-07-21 8:00 ` Mark Geisert [this message]
2021-07-21 8:09 ` [PATCH] Cygwin: fix format warnings in profiler.cc Corinna Vinschen
2021-07-21 8:07 ` [PATCH 1/3] Cygwin: New tool: profiler Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210721080040.55316-1-mark@maxrnd.com \
--to=mark@maxrnd.com \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).