changeset 20746:ee2743bd07a8

eliminate various compiler warnings
author John W. Eaton <jwe@octave.org>
date Tue, 24 Nov 2015 15:03:29 -0500
parents 69aeef6736df
children bb219f1d92db
files libinterp/corefcn/file-io.cc libinterp/corefcn/oct-stream.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-class.cc libinterp/octave-value/ov-struct.cc libinterp/octave.cc
diffstat 6 files changed, 19 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc
+++ b/libinterp/corefcn/file-io.cc
@@ -1337,7 +1337,7 @@
       error ("fread: invalid PRECISION specified");
     }
 
-  int skip;
+  int skip = 0;
 
   try
     {
@@ -1595,7 +1595,7 @@
       error ("fwrite: invalid PRECISION specified");
     }
 
-  int skip;
+  int skip = 0;
 
   try
     {
--- a/libinterp/corefcn/oct-stream.cc
+++ b/libinterp/corefcn/oct-stream.cc
@@ -61,11 +61,11 @@
 static int
 convert_to_valid_int (const octave_value& tc, int& conv_err)
 {
+  conv_err = 0;
+
   int retval = 0;
 
-  conv_err = 0;
-
-  double dval;
+  double dval = 0.0;
 
   try
     {
@@ -76,17 +76,20 @@
       conv_err = 1;
     }
 
-  if (! lo_ieee_isnan (dval))
+  if (! conv_err)
     {
-      int ival = NINT (dval);
-
-      if (ival == dval)
-        retval = ival;
+      if (! lo_ieee_isnan (dval))
+        {
+          int ival = NINT (dval);
+
+          if (ival == dval)
+            retval = ival;
+          else
+            conv_err = 3;
+        }
       else
-        conv_err = 3;
+        conv_err = 2;
     }
-  else
-    conv_err = 2;
 
   return retval;
 }
--- a/libinterp/octave-value/ov-base.cc
+++ b/libinterp/octave-value/ov-base.cc
@@ -458,7 +458,7 @@
   { \
     T retval = 0; \
  \
-    double d; \
+    double d = 0.0; \
  \
     try \
       { \
@@ -496,7 +496,7 @@
 int
 octave_base_value::nint_value (bool frc_str_conv) const
 {
-  double d;
+  double d = 0.0;
 
   try
     {
--- a/libinterp/octave-value/ov-class.cc
+++ b/libinterp/octave-value/ov-class.cc
@@ -261,12 +261,6 @@
   error ("%s cannot be indexed with %c", nm.c_str (), t);
 }
 
-static void
-gripe_failed_assignment (void)
-{
-  error ("assignment to class element failed");
-}
-
 Cell
 octave_class::dotref (const octave_value_list& idx)
 {
--- a/libinterp/octave-value/ov-struct.cc
+++ b/libinterp/octave-value/ov-struct.cc
@@ -91,14 +91,6 @@
   return retval;
 }
 
-#if 0
-static void
-gripe_invalid_index1 (void)
-{
-  error ("invalid index for structure array");
-}
-#endif
-
 static void
 gripe_invalid_index_for_assignment (void)
 {
@@ -112,12 +104,6 @@
 }
 
 static void
-gripe_failed_assignment (void)
-{
-  error ("assignment to structure element failed");
-}
-
-static void
 maybe_warn_invalid_field_name (const std::string& key, const char *who)
 {
   if (! valid_identifier (key))
--- a/libinterp/octave.cc
+++ b/libinterp/octave.cc
@@ -887,7 +887,7 @@
       // If we are running an executable script (#! /bin/octave) then
       // we should only see the args passed to the script.
 
-      int exit_status = 0;
+      exit_status = 0;
 
       try
         {