public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] xtensa: Properly strdup string when building reggroup
@ 2017-06-13 10:36 Stafford Horne
  2017-06-13 13:01 ` Yao Qi
  0 siblings, 1 reply; 5+ messages in thread
From: Stafford Horne @ 2017-06-13 10:36 UTC (permalink / raw)
  To: GDB patches; +Cc: Stafford Horne

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xtensa: Properly strdup string when building reggroup
  2017-06-13 10:36 [PATCH v2] xtensa: Properly strdup string when building reggroup Stafford Horne
@ 2017-06-13 13:01 ` Yao Qi
  2017-08-10 13:41   ` Stafford Horne
  0 siblings, 1 reply; 5+ messages in thread
From: Yao Qi @ 2017-06-13 13:01 UTC (permalink / raw)
  To: Stafford Horne; +Cc: GDB patches

Stafford Horne <shorne@gmail.com> writes:

> 2017-06-10  Stafford Horne  <shorne@gmail.com>
>
> 	* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.

Patch is good to me.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xtensa: Properly strdup string when building reggroup
  2017-06-13 13:01 ` Yao Qi
@ 2017-08-10 13:41   ` Stafford Horne
  2017-08-10 21:03     ` Yao Qi
  0 siblings, 1 reply; 5+ messages in thread
From: Stafford Horne @ 2017-08-10 13:41 UTC (permalink / raw)
  To: Yao Qi; +Cc: GDB patches

On Tue, Jun 13, 2017 at 02:01:35PM +0100, Yao Qi wrote:
> Stafford Horne <shorne@gmail.com> writes:
> 
> > 2017-06-10  Stafford Horne  <shorne@gmail.com>
> >
> > 	* xtensa-tdep.c (xtensa_init_reggroups): Use xstrdup for cpname.
> 
> Patch is good to me.

Thanks for the review,

Sorry, I haven't been having time to follow up on my gdb patches lately.
But I will get around to them.

How will this patch get applied?  I am not a maintainer yet.

-Stafford

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xtensa: Properly strdup string when building reggroup
  2017-08-10 13:41   ` Stafford Horne
@ 2017-08-10 21:03     ` Yao Qi
  2017-08-13 21:23       ` Stafford Horne
  0 siblings, 1 reply; 5+ messages in thread
From: Yao Qi @ 2017-08-10 21:03 UTC (permalink / raw)
  To: Stafford Horne; +Cc: GDB patches

On Thu, Aug 10, 2017 at 2:41 PM, Stafford Horne <shorne@gmail.com> wrote:
>
> How will this patch get applied?  I am not a maintainer yet.

Did you get your sourceware.org account?  I think
you got it.  You can clone read-write git, described
in https://sourceware.org/gdb/current/

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xtensa: Properly strdup string when building reggroup
  2017-08-10 21:03     ` Yao Qi
@ 2017-08-13 21:23       ` Stafford Horne
  0 siblings, 0 replies; 5+ messages in thread
From: Stafford Horne @ 2017-08-13 21:23 UTC (permalink / raw)
  To: Yao Qi; +Cc: GDB patches

On Thu, Aug 10, 2017 at 10:03:46PM +0100, Yao Qi wrote:
> On Thu, Aug 10, 2017 at 2:41 PM, Stafford Horne <shorne@gmail.com> wrote:
> >
> > How will this patch get applied?  I am not a maintainer yet.
> 
> Did you get your sourceware.org account?  I think
> you got it.  You can clone read-write git, described
> in https://sourceware.org/gdb/current/

Thank you,

You are right I do have ssh access now, after I filled in the form I didn't
get any notifications (or they went to my spam folder). 

Good to know it went through.  I'll try to commit this as my first patch.

-Stafford

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-13 21:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13 10:36 [PATCH v2] xtensa: Properly strdup string when building reggroup Stafford Horne
2017-06-13 13:01 ` Yao Qi
2017-08-10 13:41   ` Stafford Horne
2017-08-10 21:03     ` Yao Qi
2017-08-13 21:23       ` Stafford Horne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).