This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2] xtensa: Properly strdup string when building reggroup
- From: Stafford Horne <shorne at gmail dot com>
- To: GDB patches <gdb-patches at sourceware dot org>
- Cc: Stafford Horne <shorne at gmail dot com>
- Date: Tue, 13 Jun 2017 19:36:36 +0900
- Subject: [PATCH v2] xtensa: Properly strdup string when building reggroup
- Authentication-results: sourceware.org; auth=none
I noticed this while looking at the reggroup intializations. It seems
for xtensa the "cpN" reggroup->name is getting assigned to the same text
pointer for each iteration of XTENSA_MAX_COPROCESSOR.
Note 1, internally reggroup_new() does not do any xstrdup().
Note 2, I could not test this.
gdb/ChangeLog:
2017-06-10 Stafford Horne <shorne@gmail.com>
* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.
---
Changes since v1
* Instead of using 'smart' `'0' + i` formating just use xstrprintf
* Formatting suggested by Yao
gdb/xtensa-tdep.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index f9e8584..e9e88b9 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -737,17 +737,13 @@ static void
xtensa_init_reggroups (void)
{
int i;
- char cpname[] = "cp0";
xtensa_ar_reggroup = reggroup_new ("ar", USER_REGGROUP);
xtensa_user_reggroup = reggroup_new ("user", USER_REGGROUP);
xtensa_vectra_reggroup = reggroup_new ("vectra", USER_REGGROUP);
for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++)
- {
- cpname[2] = '0' + i;
- xtensa_cp[i] = reggroup_new (cpname, USER_REGGROUP);
- }
+ xtensa_cp[i] = reggroup_new (xstrprintf ("cp%d", i), USER_REGGROUP);
}
static void
--
2.9.4