use xsnprintf instead of snprintf.
authorgdbadmin <gdbadmin@sourceware.org>
Wed, 1 Sep 2010 01:53:43 +0000 (01:53 +0000)
committergdbadmin <gdbadmin@sourceware.org>
Wed, 1 Sep 2010 01:53:43 +0000 (01:53 +0000)
snprintf is not available on LynxOS, so I changed the calls to snprintf
to calls to xsnprintf, which should be strictly equivalent.

gdb/gdbserver/ChangeLog:

        * utils.c (xsnprintf): Make non-static.
        * server.h: Add xsnprintf declaration.
        * linux-low.c, nto-low.c, target.c, thread-db.c, tracepoint.c:
        replace calls to snprintf by calls to xsnprintf throughout.

gdb/ChangeLog
gdb/gdbserver/linux-low.c
gdb/gdbserver/nto-low.c
gdb/gdbserver/server.h
gdb/gdbserver/target.c
gdb/gdbserver/thread-db.c
gdb/gdbserver/tracepoint.c
gdb/gdbserver/utils.c

index add04e657834e13754606f753bd29b803c1f174a..870ee54a96d497d2b9f3539b03d1a0fc82814084 100644 (file)
@@ -1,3 +1,10 @@
+2010-09-01  Joel Brobecker  <brobecker@adacore.com>
+
+       * utils.c (xsnprintf): Make non-static.
+       * server.h: Add xsnprintf declaration.
+       * linux-low.c, nto-low.c, target.c, thread-db.c, tracepoint.c:
+       replace calls to snprintf by calls to xsnprintf throughout.
+
 2010-09-01  Joel Brobecker  <brobecker@adacore.com>
 
        * configure.ac: Add configure check for alloca.
index 714dac3a1192b2163c9d834427de35c0359e72ce..f2177ff354d44ca68695566ba618c76255fb0614 100644 (file)
@@ -4310,7 +4310,7 @@ linux_read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
   int fd, n;
   int pid = lwpid_of (get_thread_lwp (current_inferior));
 
-  snprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
+  xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
 
   fd = open (filename, O_RDONLY);
   if (fd < 0)
index 0c54b90b87866804648057a945c9d66ec2a8460b..e094e28a3d52ee28186d17af8c85f08f8b518f62 100644 (file)
@@ -174,7 +174,7 @@ do_attach (pid_t pid)
       close (nto_inferior.ctl_fd);
       init_nto_inferior (&nto_inferior);
     }
-  snprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
+  xsnprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
   nto_inferior.ctl_fd = open (nto_inferior.nto_procfs_path, O_RDWR);
   if (nto_inferior.ctl_fd == -1)
     {
index b401960f14a151cfa46a0c42d4f99e891ee1e5f0..286c80a52b9637b63c807469ff96b783187bb953 100644 (file)
@@ -473,6 +473,8 @@ void *xmalloc (size_t) ATTR_MALLOC;
 void *xrealloc (void *, size_t);
 void *xcalloc (size_t, size_t) ATTR_MALLOC;
 char *xstrdup (const char *) ATTR_MALLOC;
+int xsnprintf (char *str, size_t size, const char *format, ...)
+  ATTR_FORMAT (printf, 3, 4);;
 void freeargv (char **argv);
 void perror_with_name (const char *string);
 void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
index 4fc8c07597f643398c94f1b10da95f00b3eb94d1..21dd377f99592815e9b26b76dd4c600038fbb571 100644 (file)
@@ -139,18 +139,18 @@ target_pid_to_str (ptid_t ptid)
   static char buf[80];
 
   if (ptid_equal (ptid, minus_one_ptid))
-    snprintf (buf, sizeof (buf), "<all threads>");
+    xsnprintf (buf, sizeof (buf), "<all threads>");
   else if (ptid_equal (ptid, null_ptid))
-    snprintf (buf, sizeof (buf), "<null thread>");
+    xsnprintf (buf, sizeof (buf), "<null thread>");
   else if (ptid_get_tid (ptid) != 0)
-    snprintf (buf, sizeof (buf), "Thread %d.0x%lx",
-             ptid_get_pid (ptid), ptid_get_tid (ptid));
+    xsnprintf (buf, sizeof (buf), "Thread %d.0x%lx",
+              ptid_get_pid (ptid), ptid_get_tid (ptid));
   else if (ptid_get_lwp (ptid) != 0)
-    snprintf (buf, sizeof (buf), "LWP %d.%ld",
-             ptid_get_pid (ptid), ptid_get_lwp (ptid));
+    xsnprintf (buf, sizeof (buf), "LWP %d.%ld",
+              ptid_get_pid (ptid), ptid_get_lwp (ptid));
   else
-    snprintf (buf, sizeof (buf), "Process %d",
-             ptid_get_pid (ptid));
+    xsnprintf (buf, sizeof (buf), "Process %d",
+              ptid_get_pid (ptid));
 
   return buf;
 }
index 86c4e1814722c9f2c68366421c50c50b9db5c809..372cdbcad61c8a1071da3c13ceaf8e241a667984 100644 (file)
@@ -150,7 +150,7 @@ thread_db_err_str (td_err_e err)
       return "version mismatch between libthread_db and libpthread";
 #endif
     default:
-      snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
+      xsnprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
       return buf;
     }
 }
@@ -176,7 +176,7 @@ thread_db_state_str (td_thr_state_e state)
     case TD_THR_STOPPED_ASLEEP:
       return "stopped by debugger AND blocked";
     default:
-      snprintf (buf, sizeof (buf), "unknown thread_db state %d", state);
+      xsnprintf (buf, sizeof (buf), "unknown thread_db state %d", state);
       return buf;
     }
 }
index c2d7da83937afac60caa2f2d183b9ebe7054c5b5..f068ce41960f6dad6132933a6b9864a18c3f5241 100644 (file)
@@ -6723,7 +6723,7 @@ gdb_ust_connect_sync_socket (int pid)
   int res, fd;
   char path[UNIX_PATH_MAX];
 
-  res = snprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", SOCK_DIR, pid);
+  res = xsnprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", SOCK_DIR, pid);
   if (res >= UNIX_PATH_MAX)
     {
       trace_debug ("string overflow allocating socket name");
@@ -6739,7 +6739,7 @@ gdb_ust_connect_sync_socket (int pid)
 
   addr.sun_family = AF_UNIX;
 
-  res = snprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
+  res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
   if (res >= UNIX_PATH_MAX)
     {
       warning ("string overflow allocating socket name\n");
@@ -6964,8 +6964,8 @@ gdb_ust_socket_init (void)
   int result, fd;
   char name[UNIX_PATH_MAX];
 
-  result = snprintf (name, UNIX_PATH_MAX, "%s/gdb_ust%d",
-                    SOCK_DIR, getpid ());
+  result = xsnprintf (name, UNIX_PATH_MAX, "%s/gdb_ust%d",
+                     SOCK_DIR, getpid ());
   if (result >= UNIX_PATH_MAX)
     {
       trace_debug ("string overflow allocating socket name");
index 4c047e0f5c5bbe87d2e11253a3a3065fed077fbc..7de086c77c174dec09b83d5eb55621255b57c318 100644 (file)
@@ -244,7 +244,7 @@ get_cell (void)
 /* Stdarg wrapper around vsnprintf.
    SIZE is the size of the buffer pointed to by STR.  */
 
-static int
+int
 xsnprintf (char *str, size_t size, const char *format, ...)
 {
   va_list args;
This page took 0.044392 seconds and 4 git commands to generate.