This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch 1/3] Code cleanup: strcpy + strlen -> sprintf


Hi,

I do not understand much the reasons, maybe a fear about violating C sequence
points.  I hope it is not due to incompatible sprintf on MS-Windows CE or some
such gdbserver platform.

I would check it in with the other patches depending on this.


Thanks,
Jan


gdb/gdbserver/
2011-10-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* server.c (handle_qxfer_libraries): Replace strcpy and strlen pairs by
	sprintf.

--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -960,18 +960,11 @@ handle_qxfer_libraries (const char *annex,
       struct dll_info *dll = (struct dll_info *) dll_ptr;
       char *name;
 
-      strcpy (p, "  <library name=\"");
-      p = p + strlen (p);
       name = xml_escape_text (dll->name);
-      strcpy (p, name);
+      p += sprintf (p, "  <library name=\"%s\"><segment address=\"0x%lx\"/>"
+		       "</library>\n",
+		    name, (long) dll->base_addr);
       free (name);
-      p = p + strlen (p);
-      strcpy (p, "\"><segment address=\"");
-      p = p + strlen (p);
-      sprintf (p, "0x%lx", (long) dll->base_addr);
-      p = p + strlen (p);
-      strcpy (p, "\"/></library>\n");
-      p = p + strlen (p);
     }
 
   strcpy (p, "</library-list>\n");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]