eb9d945
[base]
eb9d945
eb9d945
2007-10-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
eb9d945
eb9d945
	Port to GDB-6.7.
eb9d945
eb9d945
Index: gdb-6.7/gdb/mi/mi-cmd-env.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/mi/mi-cmd-env.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/mi/mi-cmd-env.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -78,7 +78,8 @@ mi_cmd_env_pwd (char *command, char **ar
eb9d945
      
eb9d945
   /* Otherwise the mi level is 2 or higher.  */
8898d54
 
eb9d945
-  getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
eb9d945
+  /* Unused result.  */
eb9d945
+  1 && getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
eb9d945
   ui_out_field_string (uiout, "cwd", gdb_dirbuf);
8898d54
 
eb9d945
   return MI_CMD_DONE;
eb9d945
Index: gdb-6.7/gdb/testsuite/gdb.base/move-dir.h
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/testsuite/gdb.base/move-dir.h	2007-10-14 23:31:22.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/testsuite/gdb.base/move-dir.h	2007-10-14 23:42:39.000000000 +0200
8898d54
@@ -1,4 +1,4 @@
8898d54
-#include <stdlib.h>
8898d54
+#include <stdio.h>
8898d54
 
8898d54
 void other() {
8898d54
   const char* ostring = "other";
eb9d945
Index: gdb-6.7/gdb/testsuite/gdb.base/sigrepeat.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/testsuite/gdb.base/sigrepeat.c	2007-08-23 20:08:49.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/testsuite/gdb.base/sigrepeat.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -21,6 +21,7 @@
9231e41
 #include <stdlib.h>
8898d54
 #include <string.h>
8898d54
 #include <signal.h>
8898d54
+#include <stdlib.h>
8898d54
 #include <sys/time.h>
8898d54
 
9231e41
 static volatile int done[2];
eb9d945
Index: gdb-6.7/gdb/s390-tdep.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/s390-tdep.c	2007-10-02 21:26:42.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/s390-tdep.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -2214,6 +2214,9 @@ s390_return_value (struct gdbarch *gdbar
21721b8
 	case RETURN_VALUE_STRUCT_CONVENTION:
21721b8
 	  error (_("Cannot set function return value."));
21721b8
 	  break;
21721b8
+
21721b8
+        default:
21721b8
+      	  break;
21721b8
 	}
21721b8
     }
21721b8
   else if (out)
eb9d945
@@ -2246,6 +2249,9 @@ s390_return_value (struct gdbarch *gdbar
8898d54
 	case RETURN_VALUE_STRUCT_CONVENTION:
9231e41
 	  error (_("Function return value unknown."));
8898d54
 	  break;
8898d54
+
8898d54
+        default:
8898d54
+      	  break;
8898d54
 	}
8898d54
     }
8898d54
 
eb9d945
Index: gdb-6.7/gdb/f-exp.y
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/f-exp.y	2007-06-12 17:33:03.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/f-exp.y	2007-10-14 23:42:39.000000000 +0200
9231e41
@@ -567,6 +567,8 @@ ptype	:	typebase
8898d54
 		      case tp_function:
8898d54
 			follow_type = lookup_function_type (follow_type);
8898d54
 			break;
8898d54
+		      default:
8898d54
+			break;
8898d54
 		      }
8898d54
 		  $$ = follow_type;
8898d54
 		}
eb9d945
Index: gdb-6.7/gdb/source.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/source.c	2007-08-23 20:08:38.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/source.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -170,7 +170,7 @@ get_current_source_symtab_and_line (void
9231e41
 void
9231e41
 set_default_source_symtab_and_line (void)
8898d54
 {
8898d54
-  struct symtab_and_line cursal;
8898d54
+  struct symtab_and_line cursal = {0};
8898d54
 
9231e41
   if (!have_full_symbols () && !have_partial_symbols ())
9231e41
     error (_("No symbol table is loaded.  Use the \"file\" command."));
eb9d945
@@ -1439,7 +1439,7 @@ static void
8898d54
 line_info (char *arg, int from_tty)
8898d54
 {
8898d54
   struct symtabs_and_lines sals;
8898d54
-  struct symtab_and_line sal;
8898d54
+  struct symtab_and_line sal = {0};
8898d54
   CORE_ADDR start_pc, end_pc;
8898d54
   int i;
8898d54
 
eb9d945
Index: gdb-6.7/gdb/linespec.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/linespec.c	2007-10-14 23:31:03.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/linespec.c	2007-10-14 23:53:57.000000000 +0200
eb9d945
@@ -1654,7 +1654,7 @@ static struct symtabs_and_lines
8898d54
 find_method (int funfirstline, char ***canonical, char *saved_arg,
8898d54
 	     char *copy, struct type *t, struct symbol *sym_class)
8898d54
 {
8898d54
-  struct symtabs_and_lines values;
eb9d945
+  struct symtabs_and_lines values = { NULL }; 
eb9d945
   struct symbol *sym = NULL;
8898d54
   int i1;	/*  Counter for the symbol array.  */
8898d54
   struct symbol **sym_arr =  alloca (total_number_of_methods (t)
eb9d945
Index: gdb-6.7/gdb/gdb-events.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/gdb-events.c	2007-08-23 20:08:31.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/gdb-events.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -319,6 +319,8 @@ gdb_events_deliver (struct gdb_events *v
8898d54
 	case architecture_changed:
8898d54
 	  vector->architecture_changed ();
8898d54
 	  break;
8898d54
+	default:
8898d54
+	  break;
8898d54
 	}
8898d54
       delivering_events = event->next;
8898d54
       xfree (event);
eb9d945
Index: gdb-6.7/gdb/dwarf2read.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/dwarf2read.c	2007-10-14 23:31:22.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/dwarf2read.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -9585,6 +9585,7 @@ dwarf_decode_macros (struct line_header 
8898d54
   for (;;)
8898d54
     {
8898d54
       enum dwarf_macinfo_record_type macinfo_type;
8898d54
+      int tmp;
8898d54
 
8898d54
       /* Do we at least have room for a macinfo type byte?  */
8898d54
       if (mac_ptr >= mac_end)
eb9d945
@@ -9596,13 +9597,16 @@ dwarf_decode_macros (struct line_header 
8898d54
       macinfo_type = read_1_byte (abfd, mac_ptr);
8898d54
       mac_ptr++;
8898d54
 
8898d54
+      /* Check for a zero macinfo type which indicates the end of the macro
8898d54
+         information.  We do this as the compiler may warn us if we
8898d54
+         try and look for 0 in the switch below because 0 is not
8898d54
+         an enumerated value.  */
8898d54
+      tmp = (int)macinfo_type;
8898d54
+      if (tmp == 0)
8898d54
+	return;
9231e41
+
8898d54
       switch (macinfo_type)
8898d54
         {
8898d54
-          /* A zero macinfo type indicates the end of the macro
8898d54
-             information.  */
8898d54
-        case 0:
8898d54
-          return;
8898d54
-
8898d54
         case DW_MACINFO_define:
8898d54
         case DW_MACINFO_undef:
8898d54
           {
eb9d945
Index: gdb-6.7/gdb/stabsread.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/stabsread.c	2007-10-09 00:44:32.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/stabsread.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -1842,7 +1842,8 @@ again:
8898d54
 	  struct type *domain = read_type (pp, objfile);
8898d54
 	  struct type *return_type;
8898d54
 	  struct field *args;
8898d54
-	  int nargs, varargs;
8898d54
+	  int nargs = 0;
8898d54
+	  int varargs = 0;
8898d54
 
8898d54
 	  if (**pp != ',')
8898d54
 	    /* Invalid member type data format.  */
eb9d945
Index: gdb-6.7/gdb/dwarf2expr.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/dwarf2expr.c	2007-08-23 20:08:28.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/dwarf2expr.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -594,6 +594,8 @@ execute_stack_op (struct dwarf_expr_cont
8898d54
 	      op_ptr = read_uleb128 (op_ptr, op_end, ®);
8898d54
 	      result += reg;
8898d54
 	      break;
8898d54
+	    default:
8898d54
+	      break;
8898d54
 	    }
8898d54
 	  break;
8898d54
 
eb9d945
Index: gdb-6.7/gdb/varobj.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/varobj.c	2007-10-13 05:29:58.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/varobj.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -347,8 +347,7 @@ static struct language_specific language
8898d54
    c_value_of_variable}
8898d54
   ,
8898d54
   /* C */
8898d54
-  {
8898d54
-   vlang_c,
8898d54
+  {vlang_c,
8898d54
    c_number_of_children,
8898d54
    c_name_of_variable,
8898d54
    c_name_of_child,
eb9d945
@@ -360,8 +359,7 @@ static struct language_specific language
8898d54
    c_value_of_variable}
8898d54
   ,
8898d54
   /* C++ */
8898d54
-  {
8898d54
-   vlang_cplus,
8898d54
+  {vlang_cplus,
8898d54
    cplus_number_of_children,
8898d54
    cplus_name_of_variable,
8898d54
    cplus_name_of_child,
eb9d945
@@ -373,8 +371,7 @@ static struct language_specific language
8898d54
    cplus_value_of_variable}
8898d54
   ,
8898d54
   /* Java */
8898d54
-  {
8898d54
-   vlang_java,
8898d54
+  {vlang_java,
8898d54
    java_number_of_children,
8898d54
    java_name_of_variable,
8898d54
    java_name_of_child,
eb9d945
Index: gdb-6.7/gdb/doublest.c
9231e41
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/doublest.c	2007-08-23 20:08:28.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/doublest.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -92,15 +92,10 @@ get_field (const bfd_byte *data, enum fl
9231e41
     {
9231e41
       result |= (unsigned long)*(data + cur_byte) << cur_bitshift;
9231e41
       cur_bitshift += FLOATFORMAT_CHAR_BIT;
9231e41
-      switch (order)
9231e41
-	{
9231e41
-	case floatformat_little:
9231e41
-	  ++cur_byte;
9231e41
-	  break;
9231e41
-	case floatformat_big:
9231e41
-	  --cur_byte;
9231e41
-	  break;
9231e41
-	}
9231e41
+      if (order == floatformat_little)
9231e41
+	++cur_byte;
9231e41
+      else
9231e41
+	--cur_byte;
9231e41
     }
9231e41
   if (len < sizeof(result) * FLOATFORMAT_CHAR_BIT)
9231e41
     /* Mask out bits which are not part of the field */
eb9d945
Index: gdb-6.7/gdb/cli/cli-cmds.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/cli/cli-cmds.c	2007-08-23 20:08:47.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/cli/cli-cmds.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -320,7 +320,8 @@ pwd_command (char *args, int from_tty)
8336d58
 {
8336d58
   if (args)
8336d58
     error (_("The \"pwd\" command does not take an argument: %s"), args);
8336d58
-  getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
+  /* Unused result.  */
8336d58
+  1 && getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
 
8336d58
   if (strcmp (gdb_dirbuf, current_directory) != 0)
8336d58
     printf_unfiltered (_("Working directory %s\n (canonically %s).\n"),
eb9d945
Index: gdb-6.7/gdb/inflow.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/inflow.c	2007-08-23 20:08:35.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/inflow.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -547,17 +547,20 @@ new_tty (void)
8336d58
   if (tty != 0)
8336d58
     {
8336d58
       close (0);
8336d58
-      dup (tty);
8336d58
+      /* Unused result.  */
8336d58
+      1 && dup (tty);
8336d58
     }
8336d58
   if (tty != 1)
8336d58
     {
8336d58
       close (1);
8336d58
-      dup (tty);
8336d58
+      /* Unused result.  */
8336d58
+      1 && dup (tty);
8336d58
     }
8336d58
   if (tty != 2)
8336d58
     {
8336d58
       close (2);
8336d58
-      dup (tty);
8336d58
+      /* Unused result.  */
8336d58
+      1 && dup (tty);
8336d58
     }
8336d58
   if (tty > 2)
8336d58
     close (tty);
eb9d945
Index: gdb-6.7/gdb/linux-nat.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/linux-nat.c	2007-10-14 23:31:22.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/linux-nat.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -2895,7 +2895,8 @@ linux_nat_info_proc_cmd (char *args, int
8336d58
       sprintf (fname1, "/proc/%lld/cmdline", pid);
eb9d945
       if ((procfile = fopen (fname1, "r")) != NULL)
8336d58
 	{
8336d58
-	  fgets (buffer, sizeof (buffer), procfile);
8336d58
+	  /* Unused result.  */
8336d58
+	  1 && fgets (buffer, sizeof (buffer), procfile);
8336d58
 	  printf_filtered ("cmdline = '%s'\n", buffer);
8336d58
 	  fclose (procfile);
8336d58
 	}
eb9d945
Index: gdb-6.7/gdb/main.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/main.c	2007-08-23 20:08:36.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/main.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -193,7 +193,8 @@ captured_main (void *data)
8336d58
   line[0] = '\0';		/* Terminate saved (now empty) cmd line */
8336d58
   instream = stdin;
8336d58
 
8336d58
-  getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
+  /* Unused result.  */
8336d58
+  1 && getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
   current_directory = gdb_dirbuf;
8336d58
 
8336d58
   gdb_stdout = stdio_fileopen (stdout);
eb9d945
Index: gdb-6.7/gdb/top.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/top.c	2007-10-14 23:38:27.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/top.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -1636,7 +1636,8 @@ gdb_init (char *argv0)
8336d58
 
8336d58
   /* Run the init function of each source file */
8336d58
 
8336d58
-  getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
+  /* Unused result.  */
8336d58
+  1 && getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
8336d58
   current_directory = gdb_dirbuf;
8336d58
 
8336d58
 #ifdef __MSDOS__
eb9d945
Index: gdb-6.7/gdb/ui-file.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/ui-file.c	2007-08-23 20:08:46.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/ui-file.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -480,7 +480,8 @@ stdio_file_write (struct ui_file *file, 
8336d58
   if (stdio->magic != &stdio_file_magic)
8336d58
     internal_error (__FILE__, __LINE__,
8336d58
 		    _("stdio_file_write: bad magic number"));
8336d58
-  fwrite (buf, length_buf, 1, stdio->file);
8336d58
+  /* Unused result.  */
8336d58
+  1 && fwrite (buf, length_buf, 1, stdio->file);
8336d58
 }
8336d58
 
8336d58
 static void
eb9d945
Index: gdb-6.7/gdb/utils.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/utils.c	2007-08-23 20:08:46.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/utils.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -716,7 +716,8 @@ internal_vproblem (struct internal_probl
8336d58
 	abort ();	/* NOTE: GDB has only three calls to abort().  */
8336d58
       default:
8336d58
 	dejavu = 3;
8336d58
-	write (STDERR_FILENO, msg, sizeof (msg));
8336d58
+	/* Unused result.  */
8336d58
+	1 && write (STDERR_FILENO, msg, sizeof (msg));
8336d58
 	exit (1);
8336d58
       }
8336d58
   }
eb9d945
Index: gdb-6.7/gdb/gdbserver/gdbreplay.c
eb9d945
===================================================================
eb9d945
--- gdb-6.7.orig/gdb/gdbserver/gdbreplay.c	2007-08-23 20:08:48.000000000 +0200
eb9d945
+++ gdb-6.7/gdb/gdbserver/gdbreplay.c	2007-10-14 23:42:39.000000000 +0200
eb9d945
@@ -356,7 +356,12 @@ expect (FILE *fp)
daafa05
 	{
daafa05
 	  break;
daafa05
 	}
daafa05
-      read (remote_desc, &fromgdb, 1);
daafa05
+      if (read (remote_desc, &fromgdb, 1) != 1)
daafa05
+        {
daafa05
+	  /* Error gets reported below.  */
daafa05
+	  fromlog = 0;
daafa05
+	  break;
daafa05
+	}
daafa05
     }
daafa05
   while (fromlog == fromgdb);
daafa05
   if (fromlog != EOL)
eb9d945
@@ -383,7 +388,11 @@ play (FILE *fp)
daafa05
   while ((fromlog = logchar (fp)) != EOL)
daafa05
     {
daafa05
       ch = fromlog;
daafa05
-      write (remote_desc, &ch, 1);
daafa05
+      if (write (remote_desc, &ch, 1) != 1)
daafa05
+        {
daafa05
+	  sync_error (fp, "Sync error during write of gdb packet", ch, 0);
daafa05
+	  break;
daafa05
+	}
daafa05
     }
daafa05
 }
daafa05