From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Cc: "'Maxim Grigoriev'" <maxim@tensilica.com>
Subject: [RFA] xtensa-tdep.c ARI fixes
Date: Sat, 09 Apr 2011 09:42:00 -0000 [thread overview]
Message-ID: <003301cbf69a$71f5ed10$55e1c730$@muller@ics-cnrs.unistra.fr> (raw)
This patch removes three ARI warnings from xtensa-tdep.c
source code.
The only non-trivial change is in xtensa_register_type:
this is mainly because I do not understand the old code:
it was using both xmalloc and strdup, which should
create a memory leak, no?
But maybe I miss something?
Pierre Muller
as ARI maintainer.
2011-04-09 Pierre Muller <muller@ics.u-strasbg.fr>
ARI cleanup.
* xtensa-tdep.c (xtensa_register_type): Use xstrprintf instead of
sprintf. Simplify code.
(xtensa_register_reggroup_p): Extract assignment out of IF clause.
(call0_frame_cache): Remove && operator from end of line.
Index: xtensa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.c,v
retrieving revision 1.57
diff -u -p -r1.57 xtensa-tdep.c
--- xtensa-tdep.c 18 Mar 2011 18:52:32 -0000 1.57
+++ xtensa-tdep.c 9 Apr 2011 09:22:52 -0000
@@ -318,15 +318,14 @@ xtensa_register_type (struct gdbarch *gd
if (tp == NULL)
{
- char *name = xmalloc (16);
+ char *name = xstrprintf ("int%d", size * 8);
tp = xmalloc (sizeof (struct ctype_cache));
tp->next = tdep->type_entries;
tdep->type_entries = tp;
tp->size = size;
- sprintf (name, "int%d", size * 8);
tp->virtual_type
- = arch_integer_type (gdbarch, size * 8, 1, xstrdup
(name));
+ = arch_integer_type (gdbarch, size * 8, 1, name);
}
reg->ctype = tp->virtual_type;
@@ -843,7 +842,8 @@ xtensa_register_reggroup_p (struct gdbar
if (group == restore_reggroup)
return (regnum < gdbarch_num_regs (gdbarch)
&& (reg->flags & SAVE_REST_FLAGS) == SAVE_REST_VALID);
- if ((cp_number = xtensa_coprocessor_register_group (group)) >= 0)
+ cp_number = xtensa_coprocessor_register_group (group);
+ if (cp_number >= 0)
return rg & (xtRegisterGroupCP0 << cp_number);
else
return 1;
@@ -2715,9 +2715,9 @@ call0_frame_cache (struct frame_info *th
too bad. */
int i;
- for (i = 0;
- (i < C0_NREGS) &&
- (i == C0_RA || cache->c0.c0_rt[i].fr_reg != C0_RA);
+ for (i = 0;
+ (i < C0_NREGS)
+ && (i == C0_RA || cache->c0.c0_rt[i].fr_reg != C0_RA);
++i);
if (i >= C0_NREGS && cache->c0.c0_rt[C0_RA].fr_reg == C0_RA)
i = C0_RA;
next reply other threads:[~2011-04-09 9:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 9:42 Pierre Muller [this message]
[not found] <15837.6740910628$1302342165@news.gmane.org>
2011-04-14 20:31 ` Tom Tromey
2011-04-15 1:07 ` Maxim Grigoriev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003301cbf69a$71f5ed10$55e1c730$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=gdb-patches@sourceware.org \
--cc=maxim@tensilica.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox