From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16712 invoked by alias); 19 Jul 2005 13:03:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16569 invoked by uid 22791); 19 Jul 2005 13:03:01 -0000 Received: from ausmtp02.au.ibm.com (HELO ausmtp02.au.ibm.com) (202.81.18.187) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 19 Jul 2005 13:03:01 +0000 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp02.au.ibm.com (8.12.10/8.12.10) with ESMTP id j6JCvQnl123142 for ; Tue, 19 Jul 2005 22:57:30 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.250.237]) by sd0208e0.au.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j6JD537X091154 for ; Tue, 19 Jul 2005 23:05:03 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.12.11/8.13.3) with ESMTP id j6JD271e016537 for ; Tue, 19 Jul 2005 23:02:07 +1000 Received: from [9.181.134.203] ([9.181.134.203]) by d23av04.au.ibm.com (8.12.11/8.12.11) with ESMTP id j6JD25Mx016524; Tue, 19 Jul 2005 23:02:06 +1000 Date: Tue, 19 Jul 2005 13:03:00 -0000 From: Wu Zhou To: Mark Kettenis cc: gdb-patches@sourceware.org Subject: Re: [commit] Use xsnprint for xxx_pid_to_str() In-Reply-To: <200507182101.j6IL1CjP015639@elgar.sibelius.xs4all.nl> Message-ID: References: <200507182101.j6IL1CjP015639@elgar.sibelius.xs4all.nl> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2005-07/txt/msg00160.txt.bz2 On Mon, 18 Jul 2005, Mark Kettenis wrote: > Small simplification now that we have xsnprintf. Please do something > similar to your favourite code if it doesn't use this idiom yet. Mark, Here is a similar patch to remote_pid_to_str in remote.c: Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.194 diff -c -p -r1.194 remote.c *** remote.c 22 Jun 2005 11:42:54 -0000 1.194 --- remote.c 19 Jul 2005 12:53:37 -0000 *************** static char * *** 5316,5325 **** remote_pid_to_str (ptid_t ptid) { static char buf[32]; - int size; ! size = snprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid)); ! gdb_assert (size < sizeof buf); return buf; } --- 5316,5323 ---- remote_pid_to_str (ptid_t ptid) { static char buf[32]; ! xsnprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid)); return buf; } OK to commit? Thanks. Regards - Wu Zhou > Index: ChangeLog > from Mark Kettenis > > * target.c (normal_pid_to_str): Use xsnprintf instead of snprintf. > * bsd-uthread.c (bsd_uthread_pid_to_str): Likewise. > * inf-ttrace.c (inf_ttrace_pid_to_str): Likewise. > > Index: target.c > =================================================================== > RCS file: /cvs/src/src/gdb/target.c,v > retrieving revision 1.109 > diff -u -p -r1.109 target.c > --- target.c 28 May 2005 16:44:29 -0000 1.109 > +++ target.c 18 Jul 2005 20:51:40 -0000 > @@ -1793,10 +1793,8 @@ char * > normal_pid_to_str (ptid_t ptid) > { > static char buf[32]; > - int size; > > - size = snprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid)); > - gdb_assert (size < sizeof buf); > + xsnprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid)); > return buf; > } > > Index: bsd-uthread.c > =================================================================== > RCS file: /cvs/src/src/gdb/bsd-uthread.c,v > retrieving revision 1.5 > diff -u -p -r1.5 bsd-uthread.c > --- bsd-uthread.c 4 Jul 2005 13:38:55 -0000 1.5 > +++ bsd-uthread.c 18 Jul 2005 20:51:40 -0000 > @@ -469,11 +469,9 @@ bsd_uthread_pid_to_str (ptid_t ptid) > if (ptid_get_tid (ptid) != 0) > { > static char buf[64]; > - int size; > > - size = snprintf (buf, sizeof buf, "process %d, thread 0x%lx", > - ptid_get_pid (ptid), ptid_get_tid (ptid)); > - gdb_assert (size < sizeof buf); > + xsnprintf (buf, sizeof buf, "process %d, thread 0x%lx", > + ptid_get_pid (ptid), ptid_get_tid (ptid)); > return buf; > } > > Index: inf-ttrace.c > =================================================================== > RCS file: /cvs/src/src/gdb/inf-ttrace.c,v > retrieving revision 1.10 > diff -u -p -r1.10 inf-ttrace.c > --- inf-ttrace.c 21 Jun 2005 11:58:39 -0000 1.10 > +++ inf-ttrace.c 18 Jul 2005 20:51:40 -0000 > @@ -909,11 +909,9 @@ inf_ttrace_pid_to_str (ptid_t ptid) > pid_t pid = ptid_get_pid (ptid); > lwpid_t lwpid = ptid_get_lwp (ptid); > static char buf[128]; > - int size; > > - size = snprintf (buf, sizeof buf, "process %ld, lwp %ld", > - (long)pid, (long)lwpid); > - gdb_assert (size < sizeof buf); > + xsnprintf (buf, sizeof buf, "process %ld, lwp %ld", > + (long)pid, (long)lwpid); > return buf; > } > > >