From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 1/3 OBV] Fix -Wformat warnings in gnu-nat.c
Date: Fri, 07 Feb 2014 08:01:00 -0000 [thread overview]
Message-ID: <1391759958-972-2-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1391759958-972-1-git-send-email-yao@codesourcery.com>
I've seen some -Wformat warnings when build native gdb for hurd.
../../../git/gdb/gnu-nat.c:2384:8: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'vm_address_t' [-Werror=format]
../../../git/gdb/gnu-nat.c:2394:8: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'vm_address_t' [-Werror=format]
../../../git/gdb/gnu-nat.c: In function 'steal_exc_port':
../../../git/gdb/gnu-nat.c:2898:5: error: format '%d' expects argument of type 'int', but argument 2 has type 'mach_port_t' [-Werror=format]
in usr/include/mach/port.h, we have:
typedef vm_offset_t mach_port_t;
and in usr/include/mach/machine/vm_types.h, we have:
typedef unsigned long vm_offset_t;
so this patch changes '%d' to '%lu' in format string for mach_port_t
variables.
Similarly, in usr/include/mach/std_types.h, we have,
typedef vm_offset_t vm_address_t;
this patch also changes '%x' to '%lx' in gnu_write_inferior.
Note that the doc mentions that mach_port_t is an unsigned int
http://www.gnu.org/software/hurd/gnumach-doc/Message-Format.html
but I get the patch aligned with the header files instead of the
doc.
gdb:
2014-02-07 Yao Qi <yao@codesourcery.com>
* gnu-nat.c (proc_get_exception_port): Use 'lu' insetad of 'd'
in format string.
(proc_steal_exc_port, make_proc, inf_set_pid): Likewise.
(inf_validate_procs, inf_signal): Likewise.
(S_exception_raise_request): Likewise.
(do_mach_notify_dead_name): Likewise.
(steal_exc_port): Likewise.
(gnu_read_inferior): Change 'copy_count''s type to
mach_msg_type_number_t.
(gnu_write_inferior): Likewise. Use 'lx' instead of 'x' in
format string.
---
gdb/gnu-nat.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index efafc35..6e65446 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -404,7 +404,7 @@ proc_get_exception_port (struct proc * proc, mach_port_t * port)
error_t
proc_set_exception_port (struct proc * proc, mach_port_t port)
{
- proc_debug (proc, "setting exception port: %d", port);
+ proc_debug (proc, "setting exception port: %lu", port);
if (proc_is_task (proc))
return task_set_exception_port (proc->port, port);
else
@@ -444,7 +444,7 @@ proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
{
error_t err = 0;
- proc_debug (proc, "inserting exception port: %d", exc_port);
+ proc_debug (proc, "inserting exception port: %lu", exc_port);
if (cur_exc_port != exc_port)
/* Put in our exception port. */
@@ -465,7 +465,7 @@ proc_steal_exc_port (struct proc *proc, mach_port_t exc_port)
proc->saved_exc_port = cur_exc_port;
}
- proc_debug (proc, "saved exception port: %d", proc->saved_exc_port);
+ proc_debug (proc, "saved exception port: %lu", proc->saved_exc_port);
if (!err)
proc->exc_port = exc_port;
@@ -577,11 +577,11 @@ make_proc (struct inf *inf, mach_port_t port, int tid)
MACH_MSG_TYPE_MAKE_SEND_ONCE,
&prev_port);
if (err)
- warning (_("Couldn't request notification for port %d: %s"),
+ warning (_("Couldn't request notification for port %lu: %s"),
port, safe_strerror (err));
else
{
- proc_debug (proc, "notifications to: %d", inf->event_port);
+ proc_debug (proc, "notifications to: %lu", inf->event_port);
if (prev_port != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), prev_port);
}
@@ -756,7 +756,7 @@ inf_set_pid (struct inf *inf, pid_t pid)
pid, safe_strerror (err));
}
- inf_debug (inf, "setting task: %d", task_port);
+ inf_debug (inf, "setting task: %lu", task_port);
if (inf->pause_sc)
task_suspend (task_port);
@@ -1080,7 +1080,7 @@ inf_validate_procs (struct inf *inf)
else
inf->threads = thread;
last = thread;
- proc_debug (thread, "new thread: %d", threads[i]);
+ proc_debug (thread, "new thread: %lu", threads[i]);
ptid = ptid_build (inf->pid, thread->tid, 0);
@@ -1345,7 +1345,7 @@ inf_signal (struct inf *inf, enum gdb_signal sig)
struct exc_state *e = &w->exc;
inf_debug (inf, "passing through exception:"
- " task = %d, thread = %d, exc = %d"
+ " task = %lu, thread = %lu, exc = %d"
", code = %d, subcode = %d",
w->thread->port, inf->task->port,
e->exception, e->code, e->subcode);
@@ -1664,7 +1664,7 @@ S_exception_raise_request (mach_port_t port, mach_port_t reply_port,
struct proc *thread = inf_port_to_thread (inf, thread_port);
inf_debug (waiting_inf,
- "thread = %d, task = %d, exc = %d, code = %d, subcode = %d",
+ "thread = %lu, task = %lu, exc = %d, code = %d, subcode = %d",
thread_port, task_port, exception, code, subcode);
if (!thread)
@@ -1700,13 +1700,13 @@ S_exception_raise_request (mach_port_t port, mach_port_t reply_port,
{
if (thread->exc_port == port)
{
- inf_debug (waiting_inf, "Handler is thread exception port <%d>",
+ inf_debug (waiting_inf, "Handler is thread exception port <%lu>",
thread->saved_exc_port);
inf->wait.exc.handler = thread->saved_exc_port;
}
else
{
- inf_debug (waiting_inf, "Handler is task exception port <%d>",
+ inf_debug (waiting_inf, "Handler is task exception port <%lu>",
inf->task->saved_exc_port);
inf->wait.exc.handler = inf->task->saved_exc_port;
gdb_assert (inf->task->exc_port == port);
@@ -1757,7 +1757,7 @@ do_mach_notify_dead_name (mach_port_t notify, mach_port_t dead_port)
{
struct inf *inf = waiting_inf;
- inf_debug (waiting_inf, "port = %d", dead_port);
+ inf_debug (waiting_inf, "port = %lu", dead_port);
if (inf->task && inf->task->port == dead_port)
{
@@ -2380,7 +2380,7 @@ gnu_write_inferior (task_t task, CORE_ADDR addr,
/* Check for holes in memory. */
if (old_address != region_address)
{
- warning (_("No memory at 0x%x. Nothing written"),
+ warning (_("No memory at 0x%lx. Nothing written"),
old_address);
err = KERN_SUCCESS;
length = 0;
@@ -2389,7 +2389,7 @@ gnu_write_inferior (task_t task, CORE_ADDR addr,
if (!(max_protection & VM_PROT_WRITE))
{
- warning (_("Memory at address 0x%x is unwritable. "
+ warning (_("Memory at address 0x%lx is unwritable. "
"Nothing written"),
old_address);
err = KERN_SUCCESS;
@@ -2894,7 +2894,7 @@ steal_exc_port (struct proc *proc, mach_port_t name)
name, MACH_MSG_TYPE_COPY_SEND,
&port, &port_type);
if (err)
- error (_("Couldn't extract send right %d from inferior: %s"),
+ error (_("Couldn't extract send right %lu from inferior: %s"),
name, safe_strerror (err));
if (proc->saved_exc_port)
--
1.7.7.6
next prev parent reply other threads:[~2014-02-07 8:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-07 8:01 [PATCH 0/3] Unbreak build on hurd Yao Qi
2014-02-07 8:01 ` [PATCH 3/3] Find and link with -lmachuser -lhurduser Yao Qi
2014-02-16 7:49 ` Thomas Schwinge
2014-02-17 2:17 ` Yao Qi
2014-02-25 5:10 ` Samuel Thibault
2014-02-07 8:01 ` Yao Qi [this message]
2014-02-16 7:38 ` [PATCH 1/3 OBV] Fix -Wformat warnings in gnu-nat.c Thomas Schwinge
2014-02-17 3:32 ` Yao Qi
2014-02-07 8:01 ` [PATCH 2/3] Fix -Werror=pointer-sign warnings Yao Qi
2014-02-07 11:42 ` Joel Brobecker
2014-02-16 7:39 ` Thomas Schwinge
2014-02-17 3:32 ` Yao Qi
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=1391759958-972-2-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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