Mercurial > octave-nkf
changeset 18710:5bd1ca29c5f0
Clean up questionable code bits identified by clang sanitize.
* data.cc (Fnorm): in %!test, don't test with a single value which exceeds
range of single.
* find.cc (find_nonzero_elem_idx): Remove unused variable assignment to
n_to_find.
* load-save.cc (Fsave): Declare argc just before usage.
* ls-hdf5.cc (hdf5_read_next_data): Return from function immediately if type is
unrecognized.
* oct-stream.cc (octave_stream::read): Eliminate unnecessary initialization of
elts_to_read.
* octave-link.cc (F__octave_link_file_dialog__): Eliminate unnecessary
initialization of nel.
* pr-output.cc (set_real_format): Don't assign to function input variable
digits.
* str2double.cc (single_num): Initialize return value num at start of function.
* ov-complex.cc (octave_complex::double_value, octave_complex::float_value):
Eliminate unnecessary initialization of retval.
* ov-flt-complex.cc (octave_float_complex::double_value,
octave_float_complex::float_value):
Eliminate unnecessary initialization of retval.
* CSparse.cc (SparseComplexMatrix::inverse): Remove useless asignment to typ.
* CSparse.cc (SparseComplexMatrix::bsolve): Initialize anorm before using in
comparison.
* MatrixType.cc (matrix_complex_probe): Initialize typ to MatrixType::Unknown.
* dSparse.cc (SparseMatrix::inverse): Remove useless assignment to typ.
* dSparse.cc (SparseMatrix::bsolve): Initialize anorm before using in
comparison.
* lo-specfun.cc (gammainc): Remove useless assignment to err.
* data-conv.cc (oct_data_conv::string_to_data_type): Remove useless assignment
to input_is_output.
* str-vec.cc (string_vector::list_in_columns): Remove useless assignment to nc.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 25 Apr 2014 10:02:10 -0700 |
parents | 1dcc9539234c |
children | f684f7075aee |
files | libinterp/corefcn/data.cc libinterp/corefcn/find.cc libinterp/corefcn/load-save.cc libinterp/corefcn/ls-hdf5.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/octave-link.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/str2double.cc libinterp/octave-value/ov-complex.cc libinterp/octave-value/ov-flt-complex.cc liboctave/array/CSparse.cc liboctave/array/MatrixType.cc liboctave/array/dSparse.cc liboctave/numeric/lo-specfun.cc liboctave/util/data-conv.cc liboctave/util/str-vec.cc |
diffstat | 16 files changed, 24 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/data.cc Fri Apr 25 10:02:10 2014 -0700 @@ -5353,7 +5353,7 @@ %!assert (norm (x,"inf"), single (7)) %!assert (norm (x,"fro"), single (10), -eps ("single")) %!assert (norm (x), single (10)) -%!assert (norm (single ([1e200, 1])), single (1e200)) +%!assert (norm (single ([1e38, 1])), single (1e38)) %!assert (norm (single ([3+4i, 3-4i, sqrt(31)])), single (9), -4*eps ("single")) %!shared m %! m = single (magic (4));
--- a/libinterp/corefcn/find.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/find.cc Fri Apr 25 10:02:10 2014 -0700 @@ -239,7 +239,6 @@ if (n_to_find < 0 || n_to_find >= nc) { start_nc = 0; - n_to_find = nc; count = nc; } else if (direction > 0)
--- a/libinterp/corefcn/load-save.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/load-save.cc Fri Apr 25 10:02:10 2014 -0700 @@ -1623,8 +1623,6 @@ { octave_value_list retval; - int argc = args.length (); - string_vector argv = args.make_argv (); if (error_state) @@ -1648,7 +1646,7 @@ // override from command line argv = parse_save_options (argv, format, append, save_as_floats, use_zlib); - argc = argv.length (); + int argc = argv.length (); int i = 0; if (error_state)
--- a/libinterp/corefcn/ls-hdf5.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/ls-hdf5.cc Fri Apr 25 10:02:10 2014 -0700 @@ -528,6 +528,7 @@ { warning ("load: can't read '%s' (unknown datatype)", name); retval = 0; // unknown datatype; skip + return retval; } // check for OCTAVE_GLOBAL attribute:
--- a/libinterp/corefcn/oct-stream.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/oct-stream.cc Fri Apr 25 10:02:10 2014 -0700 @@ -3312,8 +3312,7 @@ if (! error_state) { - octave_idx_type elts_to_read - = std::numeric_limits<octave_idx_type>::max (); + octave_idx_type elts_to_read; if (one_elt_size_spec) { @@ -3342,7 +3341,9 @@ nr = nc = 0; } - // FIXME: ensure that this does not overflow. + // FIXME: Ensure that this does not overflow. + // Maybe try comparing nr * nc computed in double with + // std::numeric_limits<octave_idx_type>::max (); elts_to_read = nr * nc;
--- a/libinterp/corefcn/octave-link.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/octave-link.cc Fri Apr 25 10:02:10 2014 -0700 @@ -225,7 +225,7 @@ std::string multi_on = args(4).string_value (); // on, off, create std::string pathname = args(5).string_value (); - octave_idx_type nel = flist.numel (); + octave_idx_type nel; octave_link::filter_list filter_lst; for (octave_idx_type i = 0; i < flist.rows (); i++)
--- a/libinterp/corefcn/pr-output.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/pr-output.cc Fri Apr 25 10:02:10 2014 -0700 @@ -581,13 +581,11 @@ { ld = digits; rd = prec > digits ? prec - digits : prec; - digits++; } else { ld = 1; rd = prec > digits ? prec - digits : prec; - digits = -digits + 1; } fw = 1 + ld + 1 + rd;
--- a/libinterp/corefcn/str2double.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/corefcn/str2double.cc Fri Apr 25 10:02:10 2014 -0700 @@ -45,7 +45,7 @@ static double single_num (std::istringstream& is) { - double num; + double num = 0.0; char c = is.peek ();
--- a/libinterp/octave-value/ov-complex.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/octave-value/ov-complex.cc Fri Apr 25 10:02:10 2014 -0700 @@ -105,7 +105,7 @@ double octave_complex::double_value (bool force_conversion) const { - double retval = lo_ieee_nan_value (); + double retval; if (! force_conversion) gripe_implicit_conversion ("Octave:imag-to-real", @@ -119,7 +119,7 @@ float octave_complex::float_value (bool force_conversion) const { - float retval = lo_ieee_float_nan_value (); + float retval; if (! force_conversion) gripe_implicit_conversion ("Octave:imag-to-real",
--- a/libinterp/octave-value/ov-flt-complex.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/libinterp/octave-value/ov-flt-complex.cc Fri Apr 25 10:02:10 2014 -0700 @@ -89,7 +89,7 @@ double octave_float_complex::double_value (bool force_conversion) const { - double retval = lo_ieee_nan_value (); + double retval; if (! force_conversion) gripe_implicit_conversion ("Octave:imag-to-real", @@ -103,7 +103,7 @@ float octave_float_complex::float_value (bool force_conversion) const { - float retval = lo_ieee_float_nan_value (); + float retval; if (! force_conversion) gripe_implicit_conversion ("Octave:imag-to-real",
--- a/liboctave/array/CSparse.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/array/CSparse.cc Fri Apr 25 10:02:10 2014 -0700 @@ -1118,7 +1118,6 @@ { // Matrix is either singular or not positive definite mattype.mark_as_unsymmetric (); - typ = MatrixType::Full; } } @@ -4529,7 +4528,7 @@ m_band(ridx (i) - j + n_lower + n_upper, j) = data (i); // Calculate the norm of the matrix, for later use. - double anorm; + double anorm = 0.0; if (calc_cond) { for (octave_idx_type j = 0; j < nr; j++) @@ -4811,7 +4810,7 @@ m_band(ridx (i) - j + n_lower + n_upper, j) = data (i); // Calculate the norm of the matrix, for later use. - double anorm; + double anorm = 0.0; if (calc_cond) { for (octave_idx_type j = 0; j < nr; j++) @@ -5096,7 +5095,7 @@ m_band(ridx (i) - j + n_lower + n_upper, j) = data (i); // Calculate the norm of the matrix, for later use. - double anorm; + double anorm = 0.0; if (calc_cond) { for (octave_idx_type j = 0; j < nr; j++) @@ -5383,7 +5382,7 @@ m_band(ridx (i) - j + n_lower + n_upper, j) = data (i); // Calculate the norm of the matrix, for later use. - double anorm; + double anorm = 0.0; if (calc_cond) { for (octave_idx_type j = 0; j < nr; j++)
--- a/liboctave/array/MatrixType.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/array/MatrixType.cc Fri Apr 25 10:02:10 2014 -0700 @@ -119,7 +119,7 @@ MatrixType::matrix_type matrix_complex_probe (const MArray<std::complex<T> >& a) { - MatrixType::matrix_type typ; + MatrixType::matrix_type typ = MatrixType::Unknown; octave_idx_type nrows = a.rows (); octave_idx_type ncols = a.cols ();
--- a/liboctave/array/dSparse.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/array/dSparse.cc Fri Apr 25 10:02:10 2014 -0700 @@ -1216,7 +1216,6 @@ { // Matrix is either singular or not positive definite mattype.mark_as_unsymmetric (); - typ = MatrixType::Full; } } @@ -4646,7 +4645,7 @@ m_band(ridx (i) - j + n_lower + n_upper, j) = data (i); // Calculate the norm of the matrix, for later use. - double anorm; + double anorm = 0.0; if (calc_cond) { for (octave_idx_type j = 0; j < nr; j++)
--- a/liboctave/numeric/lo-specfun.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/numeric/lo-specfun.cc Fri Apr 25 10:02:10 2014 -0700 @@ -2578,12 +2578,8 @@ err = false; if (a < 0.0 || x < 0.0) - { - (*current_liboctave_error_handler) - ("gammainc: A and X must be non-negative"); - - err = true; - } + (*current_liboctave_error_handler) + ("gammainc: A and X must be non-negative"); else F77_XFCN (xgammainc, XGAMMAINC, (a, x, retval)); @@ -2783,12 +2779,8 @@ err = false; if (a < 0.0 || x < 0.0) - { - (*current_liboctave_error_handler) - ("gammainc: A and X must be non-negative"); - - err = true; - } + (*current_liboctave_error_handler) + ("gammainc: A and X must be non-negative"); else F77_XFCN (xsgammainc, XSGAMMAINC, (a, x, retval));
--- a/liboctave/util/data-conv.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/util/data-conv.cc Fri Apr 25 10:02:10 2014 -0700 @@ -409,8 +409,6 @@ if (input_is_output) { - input_is_output = false; - s1 = s.substr (1, pos-1); (*current_liboctave_warning_handler)
--- a/liboctave/util/str-vec.cc Thu Apr 24 14:03:46 2014 -0700 +++ b/liboctave/util/str-vec.cc Fri Apr 25 10:02:10 2014 -0700 @@ -250,14 +250,10 @@ nc = 1; // Calculate the number of rows that will be in each column except - // possibly for a short column on the right. + // possibly for a short column on the right. octave_idx_type nr = total_names / nc + (total_names % nc != 0); - // Recalculate columns based on rows. - - nc = total_names / nr + (total_names % nr != 0); - octave_idx_type count; for (octave_idx_type row = 0; row < nr; row++) {