This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Pedro Alves'" <pedro at codesourcery dot com>, <gdb-patches at sourceware dot org>
- Date: Tue, 19 Apr 2011 16:13:22 +0200
- Subject: RE: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
- References: <000901cbfe97$9ed7f120$dc87d360$@muller@ics-cnrs.unistra.fr> <201104191501.53552.pedro@codesourcery.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pedro Alves
> Envoyé?: mardi 19 avril 2011 16:02
> À?: gdb-patches@sourceware.org
> Cc?: Pierre Muller
> Objet?: Re: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
>
> On Tuesday 19 April 2011 14:42:25, Pierre Muller wrote:
> > If I understand the code correctly, this patch
> > should have no effect, the only thing that could have is
> > an unnecessary call to strchr.
> > The other alternative would be to
> > do a
> > + if (*name == ':')
> > + retrun NULL;
> > + pp = (char *) strchr (name, ':');
> > + if (pp == NULL)
> > would that be better?
>
> Yes, okay with that change.
Thanks,
here is what I checked in.
Pierre
2011-04-19 Pierre Muller <muller@ics.u-strasbg.fr>
* xcoffread.c (process_xcoff_symbol): ARI fix: Avoid assignment
inside if clause.
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.85
diff -u -p -r1.85 xcoffread.c
--- xcoffread.c 4 Apr 2011 14:29:27 -0000 1.85
+++ xcoffread.c 19 Apr 2011 14:10:54 -0000
@@ -1585,7 +1585,11 @@ process_xcoff_symbol (struct coff_symbol
where we need to, which is not necessarily super-clean,
but seems workable enough. */
- if (*name == ':' || (pp = (char *) strchr (name, ':')) == NULL)
+ if (*name == ':')
+ return NULL;
+
+ pp = (char *) strchr (name, ':');
+ if (pp == NULL)
return NULL;
++pp;