From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20599 invoked by alias); 7 Feb 2014 08:01:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20346 invoked by uid 89); 7 Feb 2014 08:01:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Feb 2014 08:01:37 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WBgNR-0002Kx-W9 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 07 Feb 2014 00:01:34 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 7 Feb 2014 00:01:32 -0800 Received: from qiyao.dyndns.dyndns.org (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Fri, 7 Feb 2014 00:01:31 -0800 From: Yao Qi To: Subject: [PATCH 1/3 OBV] Fix -Wformat warnings in gnu-nat.c Date: Fri, 07 Feb 2014 08:01:00 -0000 Message-ID: <1391759958-972-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1391759958-972-1-git-send-email-yao@codesourcery.com> References: <1391759958-972-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00186.txt.bz2 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 * 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