Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
@ 2011-04-19 13:42 Pierre Muller
  2011-04-19 14:02 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Muller @ 2011-04-19 13:42 UTC (permalink / raw)
  To: gdb-patches

  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?
Or this the patch below OK?


Pierre Muller
GDB pascal language maintainer

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 13:18:53 -0000
@@ -1585,7 +1585,8 @@ 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)
+	  pp = (char *) strchr (name, ':');
+	  if (*name == ':' || pp == NULL)
 	    return NULL;
 
 	  ++pp;


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

* Re: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
  2011-04-19 13:42 [RFA] ARI fix: avoid assignment in if clause in xcoffread.c Pierre Muller
@ 2011-04-19 14:02 ` Pedro Alves
  2011-04-19 14:13   ` Pierre Muller
       [not found]   ` <36908.1941120841$1303222432@news.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Pedro Alves @ 2011-04-19 14:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pierre Muller

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.

-- 
Pedro Alves


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

* RE: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
  2011-04-19 14:02 ` Pedro Alves
@ 2011-04-19 14:13   ` Pierre Muller
       [not found]   ` <36908.1941120841$1303222432@news.gmane.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Pierre Muller @ 2011-04-19 14:13 UTC (permalink / raw)
  To: 'Pedro Alves', gdb-patches



> -----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;


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

* Re: [RFA] ARI fix: avoid assignment in if clause in xcoffread.c
       [not found]   ` <36908.1941120841$1303222432@news.gmane.org>
@ 2011-04-19 14:33     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2011-04-19 14:33 UTC (permalink / raw)
  To: Pierre Muller; +Cc: 'Pedro Alves', gdb-patches

"Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr> writes:

> +	  pp = (char *) strchr (name, ':');

The cast is useless, though, so I checked this in as obvious.

Andreas.

2011-04-19  Andreas Schwab  <schwab@linux-m68k.org>

	* xcoffread.c (process_xcoff_symbol): Remove useless cast.
	(scan_xcoff_symtab): Likewise.

--- xcoffread.c.~1.86.~	2011-04-19 16:25:37.000000000 +0200
+++ xcoffread.c	2011-04-19 16:26:41.000000000 +0200
@@ -1588,7 +1588,7 @@ process_xcoff_symbol (struct coff_symbol
 	  if (*name == ':')
 	    return NULL;
 
-	  pp = (char *) strchr (name, ':');
+	  pp = strchr (name, ':');
 	  if (pp == NULL)
 	    return NULL;
 
@@ -2623,7 +2623,7 @@ scan_xcoff_symtab (struct objfile *objfi
 	    swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
 		      &ssymnum, objfile);
 
-	    p = (char *) strchr (namestring, ':');
+	    p = strchr (namestring, ':');
 	    if (!p)
 	      continue;			/* Not a debugging symbol.   */
 

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

end of thread, other threads:[~2011-04-19 14:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-19 13:42 [RFA] ARI fix: avoid assignment in if clause in xcoffread.c Pierre Muller
2011-04-19 14:02 ` Pedro Alves
2011-04-19 14:13   ` Pierre Muller
     [not found]   ` <36908.1941120841$1303222432@news.gmane.org>
2011-04-19 14:33     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox