summaryrefslogtreecommitdiff
path: root/gdb/nto-tdep.c
diff options
context:
space:
mode:
authorPierre Muller <muller@ics.u-strasbg.fr>2012-11-13 09:46:10 +0000
committerPierre Muller <muller@ics.u-strasbg.fr>2012-11-13 09:46:10 +0000
commit6d9ff8d75c94117ba3b3560a56796186c074a3a4 (patch)
tree0d911baecbe4888bff81bfdd1e76733fac534d20 /gdb/nto-tdep.c
parent32a3483c6a01252de17dd3eea33d535fec16054e (diff)
downloadgdb-6d9ff8d75c94117ba3b3560a56796186c074a3a4.tar.gz
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/nto-tdep.c')
-rw-r--r--gdb/nto-tdep.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 7c4894638c7..dff87bbf961 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -89,7 +89,7 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
char *buf, *arch_path, *nto_root, *endian;
const char *base;
const char *arch;
- int ret;
+ int arch_len, len, ret;
#define PATH_FMT \
"%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
@@ -116,20 +116,22 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
/* In case nto_root is short, add strlen(solib)
so we can reuse arch_path below. */
- arch_path =
- alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
- strlen (solib));
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
- buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
- sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
- arch_path);
+ arch_len = (strlen (nto_root) + strlen (arch) + strlen (endian) + 2
+ + strlen (solib));
+ arch_path = alloca (arch_len);
+ xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
+
+ len = strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;
+ buf = alloca (len);
+ xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
+ arch_path);
base = lbasename (solib);
ret = openp (buf, 1, base, o_flags, temp_pathname);
if (ret < 0 && base != solib)
{
- sprintf (arch_path, "/%s", solib);
+ xsnprintf (arch_path, arch_len, "/%s", solib);
ret = open (arch_path, o_flags, 0);
if (temp_pathname)
{
@@ -170,9 +172,9 @@ nto_init_solib_absolute_prefix (void)
== BFD_ENDIAN_BIG ? "be" : "le";
}
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
+ xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian);
- sprintf (buf, "set solib-absolute-prefix %s", arch_path);
+ xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path);
execute_command (buf, 0);
}