This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob] Random cleanups


Just FYI, zap some randomly selected annoyances.

Andrew
2003-02-06  Andrew Cagney  <ac131313@redhat.com>

	* linux-proc.c: Include "gdb_stat.h" instead of <sys/stat.h>.
	* cp-valprint.c (cp_print_value_fields): Eliminate STREQN.
	* jv-typeprint.c (java_type_print_base): Ditto.
	* typeprint.c (typedef_print): Eliminate STREQ.
	* cli/cli-script.c (define_command, define_command): Ditto.
	* main.c (captured_main): Ditto.
	* values.c (lookup_internalvar): Ditto.
	* utils.c (safe_strerror, parse_escape): Eliminate assignment
	within `if' conditional.
	* linespec.c (decode_line_2): Ditto.
	* cli/cli-dump.c (bfd_openr_with_cleanup): Ditto.
	(bfd_openw_with_cleanup): Ditto.

Index: mi/ChangeLog
2003-02-06  Andrew Cagney  <ac131313@redhat.com>

	* mi-cmd-env.c: Include "gdb_stat.h" instead of <sys/stat.h>.

Index: cp-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-valprint.c,v
retrieving revision 1.17
diff -u -r1.17 cp-valprint.c
--- cp-valprint.c	17 Jan 2003 19:12:18 -0000	1.17
+++ cp-valprint.c	7 Feb 2003 00:26:28 -0000
@@ -260,8 +260,8 @@
   if ((len == n_baseclasses)
       || ((len - n_baseclasses == 1)
 	  && TYPE_HAS_VTABLE (type)
-	  && STREQN (TYPE_FIELD_NAME (type, n_baseclasses),
-		     hpacc_vtbl_ptr_name, 5))
+	  && strncmp (TYPE_FIELD_NAME (type, n_baseclasses),
+		      hpacc_vtbl_ptr_name, 5) == 0)
       || !len)
     fprintf_filtered (stream, "<No data fields>");
   else
@@ -285,7 +285,8 @@
 
 	  /* If a vtable pointer appears, we'll print it out later */
 	  if (TYPE_HAS_VTABLE (type)
-	      && STREQN (TYPE_FIELD_NAME (type, i), hpacc_vtbl_ptr_name, 5))
+	      && strncmp (TYPE_FIELD_NAME (type, i), hpacc_vtbl_ptr_name,
+			  5) == 0)
 	    continue;
 
 	  if (fields_seen)
@@ -408,9 +409,8 @@
     }				/* if there are data fields */
   /* Now print out the virtual table pointer if there is one */
   if (TYPE_HAS_VTABLE (type)
-      && STREQN (TYPE_FIELD_NAME (type, n_baseclasses),
-		 hpacc_vtbl_ptr_name, 
-		 5))
+      && strncmp (TYPE_FIELD_NAME (type, n_baseclasses),
+		  hpacc_vtbl_ptr_name, 5) == 0)
     {
       struct value *v;
       /* First get the virtual table pointer and print it out */
Index: jv-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-typeprint.c,v
retrieving revision 1.7
diff -u -r1.7 jv-typeprint.c
--- jv-typeprint.c	17 Jan 2003 19:12:19 -0000	1.7
+++ jv-typeprint.c	7 Feb 2003 00:26:28 -0000
@@ -166,12 +166,12 @@
 	    {
 	      QUIT;
 	      /* Don't print out virtual function table.  */
-	      if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
+	      if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
 		  && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
 		continue;
 
 	      /* Don't print the dummy field "class". */
-	      if (STREQN (TYPE_FIELD_NAME (type, i), "class", 5))
+	      if (strncmp (TYPE_FIELD_NAME (type, i), "class", 5) == 0)
 		continue;
 
 	      print_spaces_filtered (level + 4, stream);
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.39
diff -u -r1.39 linespec.c
--- linespec.c	4 Feb 2003 21:24:21 -0000	1.39
+++ linespec.c	7 Feb 2003 00:26:28 -0000
@@ -438,7 +438,8 @@
       i++;
     }
 
-  if ((prompt = getenv ("PS2")) == NULL)
+  prompt = getenv ("PS2");
+  if (prompt == NULL)
     {
       prompt = "> ";
     }
Index: linux-proc.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-proc.c,v
retrieving revision 1.12
diff -u -r1.12 linux-proc.c
--- linux-proc.c	26 Nov 2002 01:23:46 -0000	1.12
+++ linux-proc.c	7 Feb 2003 00:26:28 -0000
@@ -23,7 +23,7 @@
 #include "inferior.h"
 #include <sys/param.h>	/* for MAXPATHLEN */
 #include <sys/procfs.h>	/* for elf_gregset etc. */
-#include <sys/stat.h>	/* for struct stat */
+#include "gdb_stat.h"	/* for struct stat */
 #include <ctype.h>	/* for isdigit */
 #include <unistd.h>	/* for open, pread64 */
 #include <fcntl.h>	/* for O_RDONLY */
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.26
diff -u -r1.26 main.c
--- main.c	6 Feb 2003 01:19:12 -0000	1.26
+++ main.c	7 Feb 2003 00:26:28 -0000
@@ -638,7 +638,7 @@
 
   if (execarg != NULL
       && symarg != NULL
-      && STREQ (execarg, symarg))
+      && strcmp (execarg, symarg) == 0)
     {
       /* The exec file and the symbol-file are the same.  If we can't
          open it, better only print one error message.
Index: typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/typeprint.c,v
retrieving revision 1.14
diff -u -r1.14 typeprint.c
--- typeprint.c	14 Jan 2003 00:49:04 -0000	1.14
+++ typeprint.c	7 Feb 2003 00:26:28 -0000
@@ -67,15 +67,15 @@
       fprintf_filtered (stream, "typedef ");
       type_print (type, "", stream, 0);
       if (TYPE_NAME ((SYMBOL_TYPE (new))) == 0
-	  || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)))
+	  || strcmp (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)) != 0)
 	fprintf_filtered (stream, " %s", SYMBOL_SOURCE_NAME (new));
       break;
 #endif
 #ifdef _LANG_m2
     case language_m2:
       fprintf_filtered (stream, "TYPE ");
-      if (!TYPE_NAME (SYMBOL_TYPE (new)) ||
-	  !STREQ (TYPE_NAME (SYMBOL_TYPE (new)), SYMBOL_NAME (new)))
+      if (!TYPE_NAME (SYMBOL_TYPE (new))
+	  || strcmp (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)) != 0)
 	fprintf_filtered (stream, "%s = ", SYMBOL_SOURCE_NAME (new));
       else
 	fprintf_filtered (stream, "<builtin> = ");
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.95
diff -u -r1.95 utils.c
--- utils.c	4 Feb 2003 23:59:26 -0000	1.95
+++ utils.c	7 Feb 2003 00:26:28 -0000
@@ -831,7 +831,8 @@
   char *msg;
   static char buf[32];
 
-  if ((msg = strerror (errnum)) == NULL)
+  msg = strerror (errnum);
+  if (msg == NULL)
     {
       sprintf (buf, "(undocumented errno %d)", errnum);
       msg = buf;
@@ -1447,14 +1448,15 @@
 	  register int count = 0;
 	  while (++count < 3)
 	    {
-	      if ((c = *(*string_ptr)++) >= '0' && c <= '7')
+	      c = (**string_ptr);
+	      if (c >= '0' && c <= '7')
 		{
+		  (*string_ptr)++;
 		  i *= 8;
 		  i += c - '0';
 		}
 	      else
 		{
-		  (*string_ptr)--;
 		  break;
 		}
 	    }
Index: values.c
===================================================================
RCS file: /cvs/src/src/gdb/values.c,v
retrieving revision 1.45
diff -u -r1.45 values.c
--- values.c	4 Feb 2003 23:59:26 -0000	1.45
+++ values.c	7 Feb 2003 00:26:28 -0000
@@ -406,7 +406,7 @@
   register struct internalvar *var;
 
   for (var = internalvars; var; var = var->next)
-    if (STREQ (var->name, name))
+    if (strcmp (var->name, name) == 0)
       return var;
 
   var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
Index: cli/cli-dump.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-dump.c,v
retrieving revision 1.7
diff -u -r1.7 cli-dump.c
--- cli/cli-dump.c	9 Dec 2002 00:59:27 -0000	1.7
+++ cli/cli-dump.c	7 Feb 2003 00:26:28 -0000
@@ -132,7 +132,8 @@
 {
   bfd *ibfd;
 
-  if ((ibfd = bfd_openr (filename, target)) == NULL)
+  ibfd = bfd_openr (filename, target);
+  if (ibfd == NULL)
     error ("Failed to open %s: %s.", filename, 
 	   bfd_errmsg (bfd_get_error ()));
 
@@ -150,7 +151,8 @@
 
   if (*mode == 'w')	/* Write: create new file */
     {
-      if ((obfd = bfd_openw (filename, target)) == NULL)
+      obfd = bfd_openw (filename, target);
+      if (obfd == NULL)
 	error ("Failed to open %s: %s.", filename, 
 	       bfd_errmsg (bfd_get_error ()));
       make_cleanup_bfd_close (obfd);
Index: cli/cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.15
diff -u -r1.15 cli-script.c
--- cli/cli-script.c	18 Jan 2003 15:55:53 -0000	1.15
+++ cli/cli-script.c	7 Feb 2003 00:26:28 -0000
@@ -1093,7 +1093,7 @@
 
   /* Look it up, and verify that we got an exact match.  */
   c = lookup_cmd (&tem, cmdlist, "", -1, 1);
-  if (c && !STREQ (comname, c->name))
+  if (c && strcmp (comname, c->name) != 0)
     c = 0;
 
   if (c)
@@ -1126,7 +1126,7 @@
       /* Look up cmd it hooks, and verify that we got an exact match.  */
       tem = comname + hook_name_size;
       hookc = lookup_cmd (&tem, cmdlist, "", -1, 0);
-      if (hookc && !STREQ (comname + hook_name_size, hookc->name))
+      if (hookc && strcmp (comname + hook_name_size, hookc->name) != 0)
 	hookc = 0;
       if (!hookc)
 	{
Index: mi/mi-cmd-env.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-env.c,v
retrieving revision 1.3
diff -u -r1.3 mi-cmd-env.c
--- mi/mi-cmd-env.c	14 Jan 2003 00:49:06 -0000	1.3
+++ mi/mi-cmd-env.c	7 Feb 2003 00:26:28 -0000
@@ -35,7 +35,7 @@
 #include "top.h"
 
 #include "gdb_string.h"
-#include <sys/stat.h>
+#include "gdb_stat.h"
 
 static void env_cli_command (const char *cli, char *args);
 static void env_mod_path (char *dirname, char **which_path);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]