summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2005-03-13 22:06:10 +0000
committerMark Kettenis <kettenis@gnu.org>2005-03-13 22:06:10 +0000
commit279eca0814842ee5d0c1a5b3724b50fcf9b56aff (patch)
tree2800a035df218152c00c6d0288b93c4c4c656f69
parent8cb68fbb05cccb6faea70910cde1228b661f2474 (diff)
downloadgdb-279eca0814842ee5d0c1a5b3724b50fcf9b56aff.tar.gz
* inf-ttrace.c (inf_ttrace_pid_to_str): Use snprintf instead of
sprintf. * target.c (normal_pid_to_str): Likewise. * remote.c (remote_pid_to_str): Use snprint instead of sprintf. Change capitalization of "thread". Use ptid_get_pid instead of GETPID.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/inf-ttrace.c7
-rw-r--r--gdb/remote.c6
-rw-r--r--gdb/target.c10
4 files changed, 23 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eef69955610..a7a9353f1f9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,11 @@
-2005-03-13 Mark Kettenis <kettenis@gnu.org>
+2005-03-13 Mark Kettenis <kettenis@elgar.gnu.org>
+
+ * inf-ttrace.c (inf_ttrace_pid_to_str): Use snprintf instead of
+ sprintf.
+ * target.c (normal_pid_to_str): Likewise.
+ * remote.c (remote_pid_to_str): Use snprint instead of sprintf.
+ Change capitalization of "thread". Use ptid_get_pid instead of
+ GETPID.
* cp-abi.c (set_cp_abi_as_auto_default): Use xasprintf instead of
a combination of xmalloc and sprintf.
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index 253323824b9..7e3e79ac75d 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -908,9 +908,12 @@ 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[80];
+ static char buf[128];
+ int size;
- sprintf (buf, "process %ld, lwp %ld", (long)pid, (long)lwpid);
+ size = snprintf (buf, sizeof buf, "process %ld, lwp %ld",
+ (long)pid, (long)lwpid);
+ gdb_assert (size < sizeof buf);
return buf;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 317a7d53fb9..ed57631ac80 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5322,9 +5322,11 @@ Fetch and print the remote list of thread identifiers, one pkt only"));
static char *
remote_pid_to_str (ptid_t ptid)
{
- static char buf[30];
+ static char buf[32];
+ int size;
- sprintf (buf, "Thread %d", PIDGET (ptid));
+ size = snprintf (buf, sizeof buf, "thread %d", ptid_get_pid (ptid));
+ gdb_assert (size < sizeof buf);
return buf;
}
diff --git a/gdb/target.c b/gdb/target.c
index e2bb96d0ccf..a0965fd3b6f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1803,15 +1803,17 @@ store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
int (*target_activity_function) (void);
int target_activity_fd;
-/* Convert a normal process ID to a string. Returns the string in a static
- buffer. */
+/* Convert a normal process ID to a string. Returns the string in a
+ static buffer. */
char *
normal_pid_to_str (ptid_t ptid)
{
- static char buf[30];
+ static char buf[32];
+ int size;
- sprintf (buf, "process %d", PIDGET (ptid));
+ size = snprintf (buf, sizeof buf, "process %d", ptid_get_pid (ptid));
+ gdb_assert (size < sizeof buf);
return buf;
}