* [commit] Use xsnprint for xxx_pid_to_str()
@ 2005-07-18 21:01 Mark Kettenis
2005-07-19 13:03 ` Wu Zhou
0 siblings, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2005-07-18 21:01 UTC (permalink / raw)
To: gdb-patches
Small simplification now that we have xsnprintf. Please do something
similar to your favourite code if it doesn't use this idiom yet.
Committed,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* 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;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [commit] Use xsnprint for xxx_pid_to_str()
2005-07-18 21:01 [commit] Use xsnprint for xxx_pid_to_str() Mark Kettenis
@ 2005-07-19 13:03 ` Wu Zhou
2005-07-19 17:20 ` Mark Kettenis
0 siblings, 1 reply; 4+ messages in thread
From: Wu Zhou @ 2005-07-19 13:03 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
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 <kettenis@gnu.org>
>
> * 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;
> }
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [commit] Use xsnprint for xxx_pid_to_str()
2005-07-19 13:03 ` Wu Zhou
@ 2005-07-19 17:20 ` Mark Kettenis
2005-07-20 3:06 ` Wu Zhou
0 siblings, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2005-07-19 17:20 UTC (permalink / raw)
To: woodzltc; +Cc: gdb-patches
Date: Tue, 19 Jul 2005 20:57:22 +0800 (CST)
From: Wu Zhou <woodzltc@cn.ibm.com>
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.
With a proper ChangeLog entry, yes! Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [commit] Use xsnprint for xxx_pid_to_str()
2005-07-19 17:20 ` Mark Kettenis
@ 2005-07-20 3:06 ` Wu Zhou
0 siblings, 0 replies; 4+ messages in thread
From: Wu Zhou @ 2005-07-20 3:06 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Tue, 19 Jul 2005, Mark Kettenis wrote:
> With a proper ChangeLog entry, yes! Thanks,
Commited with a ChangeLog entry added. Thanks.
Regards
- Wu Zhou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-07-20 3:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-18 21:01 [commit] Use xsnprint for xxx_pid_to_str() Mark Kettenis
2005-07-19 13:03 ` Wu Zhou
2005-07-19 17:20 ` Mark Kettenis
2005-07-20 3:06 ` Wu Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox