Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Replace DEPRECATED_STREQ
@ 2008-01-16  9:55 Markus Deuling
  2008-01-16  9:59 ` Andreas Schwab
  2008-01-16 10:42 ` Mark Kettenis
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Deuling @ 2008-01-16  9:55 UTC (permalink / raw)
  To: GDB Patches; +Cc: Ulrich Weigand

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

Hi,

this patch replaces and removes DEPRECATED_STREQ. Tested on x86 and PowerPC without
regression. Is this ok to commit ?



ChangeLog:

	* rs6000-nat.c (add_vmap, vmap_ldinfo, vmap_exec): Replace
	DEPRECATED_STREQ by its expression.
	* coffread.c (coff_locate_sections, coff_symtab_read): Likewise.
	* xcoffread.c (read_xcoff_symtab, read_symbol_lineno, find_linenos)
	(scan_xcoff_symtab): Likewise.
	* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code): Likewise.
	* f-lang.c (find_common_for_function): Likewise.
	* objc-exp.y (parse_number): Likewise.

	* defs.h (DEPRECATED_STREQ): Remove.


-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com



[-- Attachment #2: diff-DEPRECATED_STREQ --]
[-- Type: text/plain, Size: 8714 bytes --]

diff -urpN src/gdb/coffread.c dev/gdb/coffread.c
--- src/gdb/coffread.c	2008-01-01 23:53:09.000000000 +0100
+++ dev/gdb/coffread.c	2008-01-16 09:48:28.000000000 +0100
@@ -198,7 +198,7 @@ coff_locate_sections (bfd *abfd, asectio
 
   csi = (struct coff_symfile_info *) csip;
   name = bfd_get_section_name (abfd, sectp);
-  if (DEPRECATED_STREQ (name, ".text"))
+  if (!strcmp (name, ".text"))
     {
       csi->textaddr = bfd_section_vma (abfd, sectp);
       csi->textsize += bfd_section_size (abfd, sectp);
@@ -207,7 +207,7 @@ coff_locate_sections (bfd *abfd, asectio
     {
       csi->textsize += bfd_section_size (abfd, sectp);
     }
-  else if (DEPRECATED_STREQ (name, ".stabstr"))
+  else if (!strcmp (name, ".stabstr"))
     {
       csi->stabstrsect = sectp;
     }
@@ -823,7 +823,7 @@ coff_symtab_read (long symtab_offset, un
 	case C_THUMBSTATFUNC:
 	  if (cs->c_name[0] == '.')
 	    {
-	      if (DEPRECATED_STREQ (cs->c_name, ".text"))
+	      if (!strcmp (cs->c_name, ".text"))
 		{
 		  /* FIXME:  don't wire in ".text" as section name
 		     or symbol name! */
@@ -947,7 +947,7 @@ coff_symtab_read (long symtab_offset, un
 	  break;
 
 	case C_FCN:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
+	  if (!strcmp (cs->c_name, ".bf"))
 	    {
 	      within_function = 1;
 
@@ -969,7 +969,7 @@ coff_symtab_read (long symtab_offset, un
 	      new->name =
 		process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved, objfile);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
+	  else if (!strcmp (cs->c_name, ".ef"))
 	    {
 	      if (!within_function)
 		error (_("Bad coff function information."));
@@ -1045,13 +1045,13 @@ coff_symtab_read (long symtab_offset, un
 	  break;
 
 	case C_BLOCK:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
+	  if (!strcmp (cs->c_name, ".bb"))
 	    {
 	      tmpaddr = cs->c_value;
 	      tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 	      push_context (++depth, tmpaddr);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
+	  else if (!strcmp (cs->c_name, ".eb"))
 	    {
 	      if (context_stack_depth <= 0)
 		{		/* We attempted to pop an empty context stack */
diff -urpN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h	2008-01-11 13:28:02.000000000 +0100
+++ dev/gdb/defs.h	2008-01-16 10:03:12.000000000 +0100
@@ -153,7 +153,6 @@ typedef bfd_vma CORE_ADDR;
    not responsible for any breakage due to code that relied on the old
    underlying implementation.  */
 
-#define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0)
 #define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0)
 
 /* Check if a character is one of the commonly used C++ marker characters.  */
diff -urpN src/gdb/f-lang.c dev/gdb/f-lang.c
--- src/gdb/f-lang.c	2008-01-01 23:53:09.000000000 +0100
+++ dev/gdb/f-lang.c	2008-01-16 09:57:18.000000000 +0100
@@ -637,8 +637,8 @@ find_common_for_function (char *name, ch
 
   while (tmp != NULL)
     {
-      if (DEPRECATED_STREQ (tmp->name, name)
-	  && DEPRECATED_STREQ (tmp->owning_function, funcname))
+      if (!strcmp (tmp->name, name)
+	  && !strcmp (tmp->owning_function, funcname))
 	return (tmp);
       else
 	tmp = tmp->next;
diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
--- src/gdb/hppa-hpux-tdep.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-hpux-tdep.c	2008-01-16 09:56:39.000000000 +0100
@@ -376,7 +376,8 @@ hppa_hpux_skip_trampoline_code (struct f
 	  ALL_MSYMBOLS (objfile, msymbol)
 	  {
 	    if (MSYMBOL_TYPE (msymbol) == mst_text
-		&& DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym)))
+		&& !strcmp (DEPRECATED_SYMBOL_NAME (msymbol),
+			    DEPRECATED_SYMBOL_NAME (msym)))
 	      {
 		function_found = 1;
 		break;
diff -urpN src/gdb/objc-exp.y dev/gdb/objc-exp.y
--- src/gdb/objc-exp.y	2008-01-10 10:37:22.000000000 +0100
+++ dev/gdb/objc-exp.y	2008-01-16 09:59:03.000000000 +0100
@@ -680,7 +680,7 @@ qualified_name:	typebase COLONCOLON name
 			    error ("`%s' is not defined as an aggregate type.",
 				   TYPE_NAME (type));
 
-			  if (!DEPRECATED_STREQ (type_name_no_tag (type), $4.ptr))
+			  if (strcmp (type_name_no_tag (type), $4.ptr))
 			    error ("invalid destructor `%s::~%s'",
 				   type_name_no_tag (type), $4.ptr);
 
diff -urpN src/gdb/rs6000-nat.c dev/gdb/rs6000-nat.c
--- src/gdb/rs6000-nat.c	2008-01-01 23:53:12.000000000 +0100
+++ dev/gdb/rs6000-nat.c	2008-01-16 09:42:29.000000000 +0100
@@ -762,7 +762,7 @@ add_vmap (LdInfo *ldi)
       last = 0;
       /* FIXME??? am I tossing BFDs?  bfd? */
       while ((last = bfd_openr_next_archived_file (abfd, last)))
-	if (DEPRECATED_STREQ (mem, last->filename))
+	if (strcmp (mem, last->filename) == 0)
 	  break;
 
       if (!last)
@@ -846,8 +846,8 @@ vmap_ldinfo (LdInfo *ldi)
 
 	  /* The filenames are not always sufficient to match on. */
 
-	  if ((name[0] == '/' && !DEPRECATED_STREQ (name, vp->name))
-	      || (memb[0] && !DEPRECATED_STREQ (memb, vp->member)))
+	  if ((name[0] == '/' && strcmp (name, vp->name))
+	      || (memb[0] && strcmp (memb, vp->member)))
 	    continue;
 
 	  /* See if we are referring to the same file.
@@ -944,17 +944,17 @@ vmap_exec (void)
 
   for (i = 0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
     {
-      if (DEPRECATED_STREQ (".text", exec_ops.to_sections[i].the_bfd_section->name))
+      if (!strcmp (".text", exec_ops.to_sections[i].the_bfd_section->name))
 	{
 	  exec_ops.to_sections[i].addr += vmap->tstart - vmap->tvma;
 	  exec_ops.to_sections[i].endaddr += vmap->tstart - vmap->tvma;
 	}
-      else if (DEPRECATED_STREQ (".data", exec_ops.to_sections[i].the_bfd_section->name))
+      else if (!strcmp (".data", exec_ops.to_sections[i].the_bfd_section->name))
 	{
 	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
 	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
 	}
-      else if (DEPRECATED_STREQ (".bss", exec_ops.to_sections[i].the_bfd_section->name))
+      else if (!strcmp (".bss", exec_ops.to_sections[i].the_bfd_section->name))
 	{
 	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
 	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
diff -urpN src/gdb/xcoffread.c dev/gdb/xcoffread.c
--- src/gdb/xcoffread.c	2008-01-01 23:53:13.000000000 +0100
+++ dev/gdb/xcoffread.c	2008-01-16 09:51:08.000000000 +0100
@@ -1251,7 +1251,7 @@ read_xcoff_symtab (struct partial_symtab
 	  break;
 
 	case C_FCN:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
+	  if (!strcmp (cs->c_name, ".bf"))
 	    {
 	      CORE_ADDR off = ANOFFSET (objfile->section_offsets,
 					SECT_OFF_TEXT (objfile));
@@ -1268,7 +1268,7 @@ read_xcoff_symtab (struct partial_symtab
 	      if (new->name != NULL)
 		SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
+	  else if (!strcmp (cs->c_name, ".ef"))
 	    {
 
 	      bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
@@ -1362,7 +1362,7 @@ read_xcoff_symtab (struct partial_symtab
 	  break;
 
 	case C_BLOCK:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
+	  if (!strcmp (cs->c_name, ".bb"))
 	    {
 	      depth++;
 	      new = push_context (depth,
@@ -1370,7 +1370,7 @@ read_xcoff_symtab (struct partial_symtab
 				   + ANOFFSET (objfile->section_offsets,
 					       SECT_OFF_TEXT (objfile))));
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
+	  else if (!strcmp (cs->c_name, ".eb"))
 	    {
 	      if (context_stack_depth <= 0)
 		{		/* We attempted to pop an empty context stack */
@@ -1666,7 +1666,7 @@ read_symbol_lineno (int symno)
       if (symbol->n_sclass == C_FCN)
 	{
 	  char *name = xcoff64 ? strtbl + symbol->n_offset : symbol->n_name;
-	  if (DEPRECATED_STREQ (name, ".bf"))
+	  if (!strcmp (name, ".bf"))
 	    goto gotit;
 	}
       symno += symbol->n_numaux + 1;
@@ -1700,7 +1700,7 @@ find_linenos (struct bfd *abfd, struct b
 
   count = asect->lineno_count;
 
-  if (!DEPRECATED_STREQ (asect->name, ".text") || count == 0)
+  if (strcmp (asect->name, ".text") || count == 0)
     return;
 
   size = count * coff_data (abfd)->local_linesz;
@@ -2525,12 +2525,12 @@ scan_xcoff_symtab (struct objfile *objfi
 	       things like "break c-exp.y:435" need to work (I
 	       suppose the psymtab_include_list could be hashed or put
 	       in a binary tree, if profiling shows this is a major hog).  */
-	    if (pst && DEPRECATED_STREQ (namestring, pst->filename))
+	    if (pst && !strcmp (namestring, pst->filename))
 	      continue;
 	    {
 	      int i;
 	      for (i = 0; i < includes_used; i++)
-		if (DEPRECATED_STREQ (namestring, psymtab_include_list[i]))
+		if (!strcmp (namestring, psymtab_include_list[i]))
 		  {
 		    i = -1;
 		    break;


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

* Re: [rfc] Replace DEPRECATED_STREQ
  2008-01-16  9:55 [rfc] Replace DEPRECATED_STREQ Markus Deuling
@ 2008-01-16  9:59 ` Andreas Schwab
  2008-01-16 11:08   ` Markus Deuling
  2008-01-16 10:42 ` Mark Kettenis
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2008-01-16  9:59 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches, Ulrich Weigand

Markus Deuling <deuling@de.ibm.com> writes:

> diff -urpN src/gdb/coffread.c dev/gdb/coffread.c
> --- src/gdb/coffread.c	2008-01-01 23:53:09.000000000 +0100
> +++ dev/gdb/coffread.c	2008-01-16 09:48:28.000000000 +0100
> @@ -198,7 +198,7 @@ coff_locate_sections (bfd *abfd, asectio
>  
>    csi = (struct coff_symfile_info *) csip;
>    name = bfd_get_section_name (abfd, sectp);
> -  if (DEPRECATED_STREQ (name, ".text"))
> +  if (!strcmp (name, ".text"))

I think you should generally use strcmp (...) == 0, since the return
value is not a boolean.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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

* Re: [rfc] Replace DEPRECATED_STREQ
  2008-01-16  9:55 [rfc] Replace DEPRECATED_STREQ Markus Deuling
  2008-01-16  9:59 ` Andreas Schwab
@ 2008-01-16 10:42 ` Mark Kettenis
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2008-01-16 10:42 UTC (permalink / raw)
  To: deuling; +Cc: gdb-patches, uweigand

> Date: Wed, 16 Jan 2008 10:52:43 +0100
> From: Markus Deuling <deuling@de.ibm.com>
> 
> Hi,
> 
> this patch replaces and removes DEPRECATED_STREQ. Tested on x86 and
> PowerPC without regression. Is this ok to commit ?

Please, please, use

    if (strcmp(a, b) == 0)

instead of

    if (!strcmp(a, b))

I always read the latter as exactly the opposite of what it really
means, and the former is the prevalent way of coding this everywhere
else in GDB.

Mark

> ChangeLog:
> 
> 	* rs6000-nat.c (add_vmap, vmap_ldinfo, vmap_exec): Replace
> 	DEPRECATED_STREQ by its expression.
> 	* coffread.c (coff_locate_sections, coff_symtab_read): Likewise.
> 	* xcoffread.c (read_xcoff_symtab, read_symbol_lineno, find_linenos)
> 	(scan_xcoff_symtab): Likewise.
> 	* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code): Likewise.
> 	* f-lang.c (find_common_for_function): Likewise.
> 	* objc-exp.y (parse_number): Likewise.
> 
> 	* defs.h (DEPRECATED_STREQ): Remove.
> 
> 
> -- 
>   Markus Deuling
>   GNU Toolchain for Linux on Cell BE
>   deuling@de.ibm.com
> 
> 
> 
> --------------060202000806010607000108
> Content-Type: text/plain;
>  name="diff-DEPRECATED_STREQ"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
>  filename="diff-DEPRECATED_STREQ"
> 
> diff -urpN src/gdb/coffread.c dev/gdb/coffread.c
> --- src/gdb/coffread.c	2008-01-01 23:53:09.000000000 +0100
> +++ dev/gdb/coffread.c	2008-01-16 09:48:28.000000000 +0100
> @@ -198,7 +198,7 @@ coff_locate_sections (bfd *abfd, asectio
>  
>    csi = (struct coff_symfile_info *) csip;
>    name = bfd_get_section_name (abfd, sectp);
> -  if (DEPRECATED_STREQ (name, ".text"))
> +  if (!strcmp (name, ".text"))
>      {
>        csi->textaddr = bfd_section_vma (abfd, sectp);
>        csi->textsize += bfd_section_size (abfd, sectp);
> @@ -207,7 +207,7 @@ coff_locate_sections (bfd *abfd, asectio
>      {
>        csi->textsize += bfd_section_size (abfd, sectp);
>      }
> -  else if (DEPRECATED_STREQ (name, ".stabstr"))
> +  else if (!strcmp (name, ".stabstr"))
>      {
>        csi->stabstrsect = sectp;
>      }
> @@ -823,7 +823,7 @@ coff_symtab_read (long symtab_offset, un
>  	case C_THUMBSTATFUNC:
>  	  if (cs->c_name[0] == '.')
>  	    {
> -	      if (DEPRECATED_STREQ (cs->c_name, ".text"))
> +	      if (!strcmp (cs->c_name, ".text"))
>  		{
>  		  /* FIXME:  don't wire in ".text" as section name
>  		     or symbol name! */
> @@ -947,7 +947,7 @@ coff_symtab_read (long symtab_offset, un
>  	  break;
>  
>  	case C_FCN:
> -	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
> +	  if (!strcmp (cs->c_name, ".bf"))
>  	    {
>  	      within_function = 1;
>  
> @@ -969,7 +969,7 @@ coff_symtab_read (long symtab_offset, un
>  	      new->name =
>  		process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved, objfile);
>  	    }
> -	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
> +	  else if (!strcmp (cs->c_name, ".ef"))
>  	    {
>  	      if (!within_function)
>  		error (_("Bad coff function information."));
> @@ -1045,13 +1045,13 @@ coff_symtab_read (long symtab_offset, un
>  	  break;
>  
>  	case C_BLOCK:
> -	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
> +	  if (!strcmp (cs->c_name, ".bb"))
>  	    {
>  	      tmpaddr = cs->c_value;
>  	      tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
>  	      push_context (++depth, tmpaddr);
>  	    }
> -	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
> +	  else if (!strcmp (cs->c_name, ".eb"))
>  	    {
>  	      if (context_stack_depth <= 0)
>  		{		/* We attempted to pop an empty context stack */
> diff -urpN src/gdb/defs.h dev/gdb/defs.h
> --- src/gdb/defs.h	2008-01-11 13:28:02.000000000 +0100
> +++ dev/gdb/defs.h	2008-01-16 10:03:12.000000000 +0100
> @@ -153,7 +153,6 @@ typedef bfd_vma CORE_ADDR;
>     not responsible for any breakage due to code that relied on the old
>     underlying implementation.  */
>  
> -#define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0)
>  #define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0)
>  
>  /* Check if a character is one of the commonly used C++ marker characters.  */
> diff -urpN src/gdb/f-lang.c dev/gdb/f-lang.c
> --- src/gdb/f-lang.c	2008-01-01 23:53:09.000000000 +0100
> +++ dev/gdb/f-lang.c	2008-01-16 09:57:18.000000000 +0100
> @@ -637,8 +637,8 @@ find_common_for_function (char *name, ch
>  
>    while (tmp != NULL)
>      {
> -      if (DEPRECATED_STREQ (tmp->name, name)
> -	  && DEPRECATED_STREQ (tmp->owning_function, funcname))
> +      if (!strcmp (tmp->name, name)
> +	  && !strcmp (tmp->owning_function, funcname))
>  	return (tmp);
>        else
>  	tmp = tmp->next;
> diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
> --- src/gdb/hppa-hpux-tdep.c	2008-01-01 23:53:10.000000000 +0100
> +++ dev/gdb/hppa-hpux-tdep.c	2008-01-16 09:56:39.000000000 +0100
> @@ -376,7 +376,8 @@ hppa_hpux_skip_trampoline_code (struct f
>  	  ALL_MSYMBOLS (objfile, msymbol)
>  	  {
>  	    if (MSYMBOL_TYPE (msymbol) == mst_text
> -		&& DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym)))
> +		&& !strcmp (DEPRECATED_SYMBOL_NAME (msymbol),
> +			    DEPRECATED_SYMBOL_NAME (msym)))
>  	      {
>  		function_found = 1;
>  		break;
> diff -urpN src/gdb/objc-exp.y dev/gdb/objc-exp.y
> --- src/gdb/objc-exp.y	2008-01-10 10:37:22.000000000 +0100
> +++ dev/gdb/objc-exp.y	2008-01-16 09:59:03.000000000 +0100
> @@ -680,7 +680,7 @@ qualified_name:	typebase COLONCOLON name
>  			    error ("`%s' is not defined as an aggregate type.",
>  				   TYPE_NAME (type));
>  
> -			  if (!DEPRECATED_STREQ (type_name_no_tag (type), $4.ptr))
> +			  if (strcmp (type_name_no_tag (type), $4.ptr))
>  			    error ("invalid destructor `%s::~%s'",
>  				   type_name_no_tag (type), $4.ptr);
>  
> diff -urpN src/gdb/rs6000-nat.c dev/gdb/rs6000-nat.c
> --- src/gdb/rs6000-nat.c	2008-01-01 23:53:12.000000000 +0100
> +++ dev/gdb/rs6000-nat.c	2008-01-16 09:42:29.000000000 +0100
> @@ -762,7 +762,7 @@ add_vmap (LdInfo *ldi)
>        last = 0;
>        /* FIXME??? am I tossing BFDs?  bfd? */
>        while ((last = bfd_openr_next_archived_file (abfd, last)))
> -	if (DEPRECATED_STREQ (mem, last->filename))
> +	if (strcmp (mem, last->filename) == 0)
>  	  break;
>  
>        if (!last)
> @@ -846,8 +846,8 @@ vmap_ldinfo (LdInfo *ldi)
>  
>  	  /* The filenames are not always sufficient to match on. */
>  
> -	  if ((name[0] == '/' && !DEPRECATED_STREQ (name, vp->name))
> -	      || (memb[0] && !DEPRECATED_STREQ (memb, vp->member)))
> +	  if ((name[0] == '/' && strcmp (name, vp->name))
> +	      || (memb[0] && strcmp (memb, vp->member)))
>  	    continue;
>  
>  	  /* See if we are referring to the same file.
> @@ -944,17 +944,17 @@ vmap_exec (void)
>  
>    for (i = 0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
>      {
> -      if (DEPRECATED_STREQ (".text", exec_ops.to_sections[i].the_bfd_section->name))
> +      if (!strcmp (".text", exec_ops.to_sections[i].the_bfd_section->name))
>  	{
>  	  exec_ops.to_sections[i].addr += vmap->tstart - vmap->tvma;
>  	  exec_ops.to_sections[i].endaddr += vmap->tstart - vmap->tvma;
>  	}
> -      else if (DEPRECATED_STREQ (".data", exec_ops.to_sections[i].the_bfd_section->name))
> +      else if (!strcmp (".data", exec_ops.to_sections[i].the_bfd_section->name))
>  	{
>  	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
>  	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
>  	}
> -      else if (DEPRECATED_STREQ (".bss", exec_ops.to_sections[i].the_bfd_section->name))
> +      else if (!strcmp (".bss", exec_ops.to_sections[i].the_bfd_section->name))
>  	{
>  	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
>  	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
> diff -urpN src/gdb/xcoffread.c dev/gdb/xcoffread.c
> --- src/gdb/xcoffread.c	2008-01-01 23:53:13.000000000 +0100
> +++ dev/gdb/xcoffread.c	2008-01-16 09:51:08.000000000 +0100
> @@ -1251,7 +1251,7 @@ read_xcoff_symtab (struct partial_symtab
>  	  break;
>  
>  	case C_FCN:
> -	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
> +	  if (!strcmp (cs->c_name, ".bf"))
>  	    {
>  	      CORE_ADDR off = ANOFFSET (objfile->section_offsets,
>  					SECT_OFF_TEXT (objfile));
> @@ -1268,7 +1268,7 @@ read_xcoff_symtab (struct partial_symtab
>  	      if (new->name != NULL)
>  		SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile);
>  	    }
> -	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
> +	  else if (!strcmp (cs->c_name, ".ef"))
>  	    {
>  
>  	      bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
> @@ -1362,7 +1362,7 @@ read_xcoff_symtab (struct partial_symtab
>  	  break;
>  
>  	case C_BLOCK:
> -	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
> +	  if (!strcmp (cs->c_name, ".bb"))
>  	    {
>  	      depth++;
>  	      new = push_context (depth,
> @@ -1370,7 +1370,7 @@ read_xcoff_symtab (struct partial_symtab
>  				   + ANOFFSET (objfile->section_offsets,
>  					       SECT_OFF_TEXT (objfile))));
>  	    }
> -	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
> +	  else if (!strcmp (cs->c_name, ".eb"))
>  	    {
>  	      if (context_stack_depth <= 0)
>  		{		/* We attempted to pop an empty context stack */
> @@ -1666,7 +1666,7 @@ read_symbol_lineno (int symno)
>        if (symbol->n_sclass == C_FCN)
>  	{
>  	  char *name = xcoff64 ? strtbl + symbol->n_offset : symbol->n_name;
> -	  if (DEPRECATED_STREQ (name, ".bf"))
> +	  if (!strcmp (name, ".bf"))
>  	    goto gotit;
>  	}
>        symno += symbol->n_numaux + 1;
> @@ -1700,7 +1700,7 @@ find_linenos (struct bfd *abfd, struct b
>  
>    count = asect->lineno_count;
>  
> -  if (!DEPRECATED_STREQ (asect->name, ".text") || count == 0)
> +  if (strcmp (asect->name, ".text") || count == 0)
>      return;
>  
>    size = count * coff_data (abfd)->local_linesz;
> @@ -2525,12 +2525,12 @@ scan_xcoff_symtab (struct objfile *objfi
>  	       things like "break c-exp.y:435" need to work (I
>  	       suppose the psymtab_include_list could be hashed or put
>  	       in a binary tree, if profiling shows this is a major hog).  */
> -	    if (pst && DEPRECATED_STREQ (namestring, pst->filename))
> +	    if (pst && !strcmp (namestring, pst->filename))
>  	      continue;
>  	    {
>  	      int i;
>  	      for (i = 0; i < includes_used; i++)
> -		if (DEPRECATED_STREQ (namestring, psymtab_include_list[i]))
> +		if (!strcmp (namestring, psymtab_include_list[i]))
>  		  {
>  		    i = -1;
>  		    break;
> 
> 
> --------------060202000806010607000108--
> 


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

* Re: [rfc] Replace DEPRECATED_STREQ
  2008-01-16  9:59 ` Andreas Schwab
@ 2008-01-16 11:08   ` Markus Deuling
  2008-01-16 11:15     ` Mark Kettenis
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Deuling @ 2008-01-16 11:08 UTC (permalink / raw)
  To: GDB Patches; +Cc: Andreas Schwab, Mark Kettenis, Ulrich Weigand

[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]

Andreas Schwab schrieb:
> Markus Deuling <deuling@de.ibm.com> writes:
> 
>> diff -urpN src/gdb/coffread.c dev/gdb/coffread.c
>> --- src/gdb/coffread.c	2008-01-01 23:53:09.000000000 +0100
>> +++ dev/gdb/coffread.c	2008-01-16 09:48:28.000000000 +0100
>> @@ -198,7 +198,7 @@ coff_locate_sections (bfd *abfd, asectio
>>  
>>    csi = (struct coff_symfile_info *) csip;
>>    name = bfd_get_section_name (abfd, sectp);
>> -  if (DEPRECATED_STREQ (name, ".text"))
>> +  if (!strcmp (name, ".text"))
> 
> I think you should generally use strcmp (...) == 0, since the return
> value is not a boolean.


Mark Kettenis schrieb:
>> this patch replaces and removes DEPRECATED_STREQ. Tested on x86 and
>> PowerPC without regression. Is this ok to commit ?
> 
> Please, please, use
> 
>     if (strcmp(a, b) == 0)
> 
> instead of
> 
>     if (!strcmp(a, b))
> 
> I always read the latter as exactly the opposite of what it really
> means, and the former is the prevalent way of coding this everywhere
> else in GDB.


Ok, ok :-) I agree strcmp (a,b) == 0 is much more readable. I reworked the patch now.

Ok to commit?


Regards, 
Markus

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: diff-DEPRECATED_STREQ --]
[-- Type: text/plain, Size: 8833 bytes --]

diff -urpN src/gdb/coffread.c dev/gdb/coffread.c
--- src/gdb/coffread.c	2008-01-01 23:53:09.000000000 +0100
+++ dev/gdb/coffread.c	2008-01-16 11:42:39.000000000 +0100
@@ -198,7 +198,7 @@ coff_locate_sections (bfd *abfd, asectio
 
   csi = (struct coff_symfile_info *) csip;
   name = bfd_get_section_name (abfd, sectp);
-  if (DEPRECATED_STREQ (name, ".text"))
+  if (strcmp (name, ".text") == 0)
     {
       csi->textaddr = bfd_section_vma (abfd, sectp);
       csi->textsize += bfd_section_size (abfd, sectp);
@@ -207,7 +207,7 @@ coff_locate_sections (bfd *abfd, asectio
     {
       csi->textsize += bfd_section_size (abfd, sectp);
     }
-  else if (DEPRECATED_STREQ (name, ".stabstr"))
+  else if (strcmp (name, ".stabstr") == 0)
     {
       csi->stabstrsect = sectp;
     }
@@ -823,7 +823,7 @@ coff_symtab_read (long symtab_offset, un
 	case C_THUMBSTATFUNC:
 	  if (cs->c_name[0] == '.')
 	    {
-	      if (DEPRECATED_STREQ (cs->c_name, ".text"))
+	      if (strcmp (cs->c_name, ".text") == 0)
 		{
 		  /* FIXME:  don't wire in ".text" as section name
 		     or symbol name! */
@@ -947,7 +947,7 @@ coff_symtab_read (long symtab_offset, un
 	  break;
 
 	case C_FCN:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
+	  if (strcmp (cs->c_name, ".bf") == 0)
 	    {
 	      within_function = 1;
 
@@ -969,7 +969,7 @@ coff_symtab_read (long symtab_offset, un
 	      new->name =
 		process_coff_symbol (&fcn_cs_saved, &fcn_aux_saved, objfile);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
+	  else if (strcmp (cs->c_name, ".ef") == 0)
 	    {
 	      if (!within_function)
 		error (_("Bad coff function information."));
@@ -1045,13 +1045,13 @@ coff_symtab_read (long symtab_offset, un
 	  break;
 
 	case C_BLOCK:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
+	  if (strcmp (cs->c_name, ".bb") == 0)
 	    {
 	      tmpaddr = cs->c_value;
 	      tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 	      push_context (++depth, tmpaddr);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
+	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
 	      if (context_stack_depth <= 0)
 		{		/* We attempted to pop an empty context stack */
diff -urpN src/gdb/defs.h dev/gdb/defs.h
--- src/gdb/defs.h	2008-01-11 13:28:02.000000000 +0100
+++ dev/gdb/defs.h	2008-01-16 11:42:39.000000000 +0100
@@ -153,7 +153,6 @@ typedef bfd_vma CORE_ADDR;
    not responsible for any breakage due to code that relied on the old
    underlying implementation.  */
 
-#define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0)
 #define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0)
 
 /* Check if a character is one of the commonly used C++ marker characters.  */
diff -urpN src/gdb/f-lang.c dev/gdb/f-lang.c
--- src/gdb/f-lang.c	2008-01-01 23:53:09.000000000 +0100
+++ dev/gdb/f-lang.c	2008-01-16 11:42:39.000000000 +0100
@@ -637,8 +637,8 @@ find_common_for_function (char *name, ch
 
   while (tmp != NULL)
     {
-      if (DEPRECATED_STREQ (tmp->name, name)
-	  && DEPRECATED_STREQ (tmp->owning_function, funcname))
+      if (strcmp (tmp->name, name) == 0
+	  && strcmp (tmp->owning_function, funcname) == 0)
 	return (tmp);
       else
 	tmp = tmp->next;
diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
--- src/gdb/hppa-hpux-tdep.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-hpux-tdep.c	2008-01-16 11:42:39.000000000 +0100
@@ -376,7 +376,8 @@ hppa_hpux_skip_trampoline_code (struct f
 	  ALL_MSYMBOLS (objfile, msymbol)
 	  {
 	    if (MSYMBOL_TYPE (msymbol) == mst_text
-		&& DEPRECATED_STREQ (DEPRECATED_SYMBOL_NAME (msymbol), DEPRECATED_SYMBOL_NAME (msym)))
+		&& strcmp (DEPRECATED_SYMBOL_NAME (msymbol),
+			    DEPRECATED_SYMBOL_NAME (msym)) == 0)
 	      {
 		function_found = 1;
 		break;
diff -urpN src/gdb/objc-exp.y dev/gdb/objc-exp.y
--- src/gdb/objc-exp.y	2008-01-10 10:37:22.000000000 +0100
+++ dev/gdb/objc-exp.y	2008-01-16 11:42:39.000000000 +0100
@@ -680,7 +680,7 @@ qualified_name:	typebase COLONCOLON name
 			    error ("`%s' is not defined as an aggregate type.",
 				   TYPE_NAME (type));
 
-			  if (!DEPRECATED_STREQ (type_name_no_tag (type), $4.ptr))
+			  if (strcmp (type_name_no_tag (type), $4.ptr) != 0)
 			    error ("invalid destructor `%s::~%s'",
 				   type_name_no_tag (type), $4.ptr);
 
diff -urpN src/gdb/rs6000-nat.c dev/gdb/rs6000-nat.c
--- src/gdb/rs6000-nat.c	2008-01-01 23:53:12.000000000 +0100
+++ dev/gdb/rs6000-nat.c	2008-01-16 11:43:43.000000000 +0100
@@ -762,7 +762,7 @@ add_vmap (LdInfo *ldi)
       last = 0;
       /* FIXME??? am I tossing BFDs?  bfd? */
       while ((last = bfd_openr_next_archived_file (abfd, last)))
-	if (DEPRECATED_STREQ (mem, last->filename))
+	if (strcmp (mem, last->filename) == 0)
 	  break;
 
       if (!last)
@@ -846,8 +846,8 @@ vmap_ldinfo (LdInfo *ldi)
 
 	  /* The filenames are not always sufficient to match on. */
 
-	  if ((name[0] == '/' && !DEPRECATED_STREQ (name, vp->name))
-	      || (memb[0] && !DEPRECATED_STREQ (memb, vp->member)))
+	  if ((name[0] == '/' && strcmp (name, vp->name) != 0)
+	      || (memb[0] && strcmp (memb, vp->member) != 0))
 	    continue;
 
 	  /* See if we are referring to the same file.
@@ -944,17 +944,19 @@ vmap_exec (void)
 
   for (i = 0; &exec_ops.to_sections[i] < exec_ops.to_sections_end; i++)
     {
-      if (DEPRECATED_STREQ (".text", exec_ops.to_sections[i].the_bfd_section->name))
+      if (strcmp (".text", exec_ops.to_sections[i].the_bfd_section->name) == 0)
 	{
 	  exec_ops.to_sections[i].addr += vmap->tstart - vmap->tvma;
 	  exec_ops.to_sections[i].endaddr += vmap->tstart - vmap->tvma;
 	}
-      else if (DEPRECATED_STREQ (".data", exec_ops.to_sections[i].the_bfd_section->name))
+      else if (strcmp (".data",
+		       exec_ops.to_sections[i].the_bfd_section->name) == 0)
 	{
 	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
 	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
 	}
-      else if (DEPRECATED_STREQ (".bss", exec_ops.to_sections[i].the_bfd_section->name))
+      else if (strcmp (".bss",
+		       exec_ops.to_sections[i].the_bfd_section->name) == 0)
 	{
 	  exec_ops.to_sections[i].addr += vmap->dstart - vmap->dvma;
 	  exec_ops.to_sections[i].endaddr += vmap->dstart - vmap->dvma;
diff -urpN src/gdb/xcoffread.c dev/gdb/xcoffread.c
--- src/gdb/xcoffread.c	2008-01-01 23:53:13.000000000 +0100
+++ dev/gdb/xcoffread.c	2008-01-16 11:42:39.000000000 +0100
@@ -1251,7 +1251,7 @@ read_xcoff_symtab (struct partial_symtab
 	  break;
 
 	case C_FCN:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bf"))
+	  if (strcmp (cs->c_name, ".bf") == 0)
 	    {
 	      CORE_ADDR off = ANOFFSET (objfile->section_offsets,
 					SECT_OFF_TEXT (objfile));
@@ -1268,7 +1268,7 @@ read_xcoff_symtab (struct partial_symtab
 	      if (new->name != NULL)
 		SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile);
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".ef"))
+	  else if (strcmp (cs->c_name, ".ef") == 0)
 	    {
 
 	      bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass,
@@ -1362,7 +1362,7 @@ read_xcoff_symtab (struct partial_symtab
 	  break;
 
 	case C_BLOCK:
-	  if (DEPRECATED_STREQ (cs->c_name, ".bb"))
+	  if (strcmp (cs->c_name, ".bb") == 0)
 	    {
 	      depth++;
 	      new = push_context (depth,
@@ -1370,7 +1370,7 @@ read_xcoff_symtab (struct partial_symtab
 				   + ANOFFSET (objfile->section_offsets,
 					       SECT_OFF_TEXT (objfile))));
 	    }
-	  else if (DEPRECATED_STREQ (cs->c_name, ".eb"))
+	  else if (strcmp (cs->c_name, ".eb") == 0)
 	    {
 	      if (context_stack_depth <= 0)
 		{		/* We attempted to pop an empty context stack */
@@ -1666,7 +1666,7 @@ read_symbol_lineno (int symno)
       if (symbol->n_sclass == C_FCN)
 	{
 	  char *name = xcoff64 ? strtbl + symbol->n_offset : symbol->n_name;
-	  if (DEPRECATED_STREQ (name, ".bf"))
+	  if (strcmp (name, ".bf") == 0)
 	    goto gotit;
 	}
       symno += symbol->n_numaux + 1;
@@ -1700,7 +1700,7 @@ find_linenos (struct bfd *abfd, struct b
 
   count = asect->lineno_count;
 
-  if (!DEPRECATED_STREQ (asect->name, ".text") || count == 0)
+  if (strcmp (asect->name, ".text") != 0 || count == 0)
     return;
 
   size = count * coff_data (abfd)->local_linesz;
@@ -2525,12 +2525,12 @@ scan_xcoff_symtab (struct objfile *objfi
 	       things like "break c-exp.y:435" need to work (I
 	       suppose the psymtab_include_list could be hashed or put
 	       in a binary tree, if profiling shows this is a major hog).  */
-	    if (pst && DEPRECATED_STREQ (namestring, pst->filename))
+	    if (pst && strcmp (namestring, pst->filename) == 0)
 	      continue;
 	    {
 	      int i;
 	      for (i = 0; i < includes_used; i++)
-		if (DEPRECATED_STREQ (namestring, psymtab_include_list[i]))
+		if (strcmp (namestring, psymtab_include_list[i]) == 0)
 		  {
 		    i = -1;
 		    break;

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

* Re: [rfc] Replace DEPRECATED_STREQ
  2008-01-16 11:08   ` Markus Deuling
@ 2008-01-16 11:15     ` Mark Kettenis
  2008-01-16 11:23       ` Markus Deuling
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Kettenis @ 2008-01-16 11:15 UTC (permalink / raw)
  To: deuling; +Cc: gdb-patches, schwab, uweigand

> Date: Wed, 16 Jan 2008 12:05:44 +0100
> From: Markus Deuling <deuling@de.ibm.com>
> Ok, ok :-) I agree strcmp (a,b) == 0 is much more readable. I reworked the patch now.
> 
> Ok to commit?

Fine with me (don't forget the ChangeLog).


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

* Re: [rfc] Replace DEPRECATED_STREQ
  2008-01-16 11:15     ` Mark Kettenis
@ 2008-01-16 11:23       ` Markus Deuling
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Deuling @ 2008-01-16 11:23 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: deuling, gdb-patches, schwab, uweigand

Mark Kettenis schrieb:
>> Date: Wed, 16 Jan 2008 12:05:44 +0100
>> From: Markus Deuling <deuling@de.ibm.com>
>> Ok, ok :-) I agree strcmp (a,b) == 0 is much more readable. I reworked the patch now.
>>
>> Ok to commit?
> 
> Fine with me (don't forget the ChangeLog).
> 

Great, thank you very much for review. Committed this one with the following
ChangeLog:

	* rs6000-nat.c (add_vmap, vmap_ldinfo, vmap_exec): Replace
	DEPRECATED_STREQ by its expression.
	* coffread.c (coff_locate_sections, coff_symtab_read): Likewise.
	* xcoffread.c (read_xcoff_symtab, read_symbol_lineno, find_linenos)
	(scan_xcoff_symtab): Likewise.
	* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code): Likewise.
	* f-lang.c (find_common_for_function): Likewise.
	* objc-exp.y (parse_number): Likewise.

	* defs.h (DEPRECATED_STREQ): Remove.


-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


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

end of thread, other threads:[~2008-01-16 11:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-16  9:55 [rfc] Replace DEPRECATED_STREQ Markus Deuling
2008-01-16  9:59 ` Andreas Schwab
2008-01-16 11:08   ` Markus Deuling
2008-01-16 11:15     ` Mark Kettenis
2008-01-16 11:23       ` Markus Deuling
2008-01-16 10:42 ` Mark Kettenis

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