aboutsummaryrefslogtreecommitdiff
path: root/gdb/source.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2012-11-13 09:46:11 +0000
committerPierre Muller <muller@sourceware.org>2012-11-13 09:46:11 +0000
commit08850b56edd752c3792bfb9bfc59dd9a5577ac2d (patch)
treedc5581a48e546d35ecdbb5a832c0a83185cb585e /gdb/source.c
parentcec6a5b82ba19f3d8155503da6d7313c9321fcf6 (diff)
downloadgdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.zip
gdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.tar.gz
gdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.tar.bz2
ARI fixes: Avoid sprintf function use rule.
* charset.c (convert_between_encodings): Use xsnprintf. * cli-out.c (cli_field_int): Likewise. * cp-namespace.c (cp_lookup_nested_symbol): Likewise. * expprint.c (op_name_standard): Likewise. * frv-tdep.c (set_variant_num_gprs): Likewise. (set_variant_num_fprs): Likewise. * m68hc11-tdep.c (m68hc11_initialize_register_info): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_init_solib_absolute_prefix): Likewise. * source.c (init_source_path): Likewise. (print_source_lines_base): Likewise. * valprint.c (print_wchar): Likewise. * mi/mi-out.c (mi_field_int): Likewise. windows-nat.c (windows_pid_to_exec_file): Likewise. (windows_create_inferior): Likewise. (_initialize_check_for_gdb_ini): Likewise.
Diffstat (limited to 'gdb/source.c')
-rw-r--r--gdb/source.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/source.c b/gdb/source.c
index 9813c43..c05822e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -384,7 +384,7 @@ init_source_path (void)
{
char buf[20];
- sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
+ xsnprintf (buf, sizeof (buf), "$cdir%c$cwd", DIRNAME_SEPARATOR);
source_path = xstrdup (buf);
forget_cached_source_info ();
}
@@ -1292,8 +1292,10 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
if (!noerror)
{
- char *name = alloca (strlen (s->filename) + 100);
- sprintf (name, "%d\t%s", line, s->filename);
+ int len = strlen (s->filename) + 100;
+ char *name = alloca (len);
+
+ xsnprintf (name, len, "%d\t%s", line, s->filename);
print_sys_errmsg (name, errno);
}
else
@@ -1344,13 +1346,13 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
if (c == EOF)
break;
last_line_listed = current_source_line;
- sprintf (buf, "%d\t", current_source_line++);
+ xsnprintf (buf, sizeof (buf), "%d\t", current_source_line++);
ui_out_text (uiout, buf);
do
{
if (c < 040 && c != '\t' && c != '\n' && c != '\r')
{
- sprintf (buf, "^%c", c + 0100);
+ xsnprintf (buf, sizeof (buf), "^%c", c + 0100);
ui_out_text (uiout, buf);
}
else if (c == 0177)
@@ -1367,7 +1369,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
}
else
{
- sprintf (buf, "%c", c);
+ xsnprintf (buf, sizeof (buf), "%c", c);
ui_out_text (uiout, buf);
}
}