# HG changeset patch # User Rik # Date 1439584110 25200 # Node ID 610c7474851861c4d1a07a75cb9f9f9eaecf74fd # Parent b22528fd3debca1b2ca744529be08b14595b0143 maint: Clean up code based on static analysis suggestions. * __dispatch__.cc (F__dispatch__): Eliminate unnecessary double check on (nargin > 0). * cellfun.cc (Fnum2cell): Eliminate duplicate else-if branch for array.is_object(). * load-save.cc: Eliminate unreachable else branch. Simplify else-if to simple else since condition is always true at this point. * matrix_type.cc (Fmatrix_type): Eliminate unnecessary check on 'str_type == upper' and just mark matrix as permuted when permutation matrix was given as input. * kpse.cc (set_end): remove unused variable and its usage in conditional. diff -r b22528fd3deb -r 610c74748518 libinterp/corefcn/__dispatch__.cc --- a/libinterp/corefcn/__dispatch__.cc Thu Aug 13 22:00:02 2015 -0700 +++ b/libinterp/corefcn/__dispatch__.cc Fri Aug 14 13:28:30 2015 -0700 @@ -50,15 +50,12 @@ if (nargin > 0 && nargin < 4) { - if (nargin > 0) - { - f = args(0).string_value (); + f = args(0).string_value (); - if (error_state) - { - error ("__dispatch__: first argument must be a function name"); - return retval; - } + if (error_state) + { + error ("__dispatch__: first argument must be a function name"); + return retval; } if (nargin > 1) diff -r b22528fd3deb -r 610c74748518 libinterp/corefcn/cellfun.cc --- a/libinterp/corefcn/cellfun.cc Thu Aug 13 22:00:02 2015 -0700 +++ b/libinterp/corefcn/cellfun.cc Fri Aug 14 13:28:30 2015 -0700 @@ -1959,8 +1959,6 @@ retval = do_num2cell (array.map_value (), dimv); else if (array.is_cell ()) retval = do_num2cell (array.cell_value (), dimv); - else if (array.is_object ()) - retval = do_num2cell (array.cell_value (), dimv); else gripe_wrong_type_arg ("num2cell", array); } diff -r b22528fd3deb -r 610c74748518 libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Thu Aug 13 22:00:02 2015 -0700 +++ b/libinterp/corefcn/load-save.cc Fri Aug 14 13:28:30 2015 -0700 @@ -400,7 +400,7 @@ if (error_state || stream.eof () || name.empty ()) break; - else if (! error_state && ! name.empty ()) + else { if (tc.is_defined ()) { @@ -455,14 +455,6 @@ else error ("load: unable to load variable '%s'", name.c_str ()); } - else - { - if (count == 0) - error ("load: are you sure '%s' is an Octave data file?", - orig_fname.c_str ()); - - break; - } } if (list_only && count) diff -r b22528fd3deb -r 610c74748518 libinterp/corefcn/matrix_type.cc --- a/libinterp/corefcn/matrix_type.cc Thu Aug 13 22:00:02 2015 -0700 +++ b/libinterp/corefcn/matrix_type.cc Fri Aug 14 13:28:30 2015 -0700 @@ -306,10 +306,7 @@ (perm (i)) - 1; - if (str_typ == "upper") - mattyp.mark_as_permuted (len, p); - else - mattyp.mark_as_permuted (len, p); + mattyp.mark_as_permuted (len, p); } } } @@ -479,10 +476,7 @@ (perm (i)) - 1; - if (str_typ == "upper") - mattyp.mark_as_permuted (len, p); - else - mattyp.mark_as_permuted (len, p); + mattyp.mark_as_permuted (len, p); } } } diff -r b22528fd3deb -r 610c74748518 liboctave/util/kpse.cc --- a/liboctave/util/kpse.cc Thu Aug 13 22:00:02 2015 -0700 +++ b/liboctave/util/kpse.cc Fri Aug 14 13:28:30 2015 -0700 @@ -485,9 +485,7 @@ { /* Find the next colon not enclosed by braces (or the end of the path). */ - - int brace_level = 0; - while (e < len && ! (brace_level == 0 && kpse_is_env_sep (path[e]))) + while (e < len && ! kpse_is_env_sep (path[e])) e++; } }