Mercurial > octave
changeset 20825:66cd994d1b79
eliminate return statements after calls to error
* __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_fltk__.cc, __magick_read__.cc, __osmesa_print__.cc,
__voronoi__.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, colamd.cc,
convhulln.cc: Eliminate return statements after calls to error.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 08 Dec 2015 14:20:05 -0500 |
parents | 8848e35e5ef8 |
children | 779898f2a02a |
files | libinterp/dldfcn/__delaunayn__.cc libinterp/dldfcn/__eigs__.cc libinterp/dldfcn/__fltk_uigetfile__.cc libinterp/dldfcn/__glpk__.cc libinterp/dldfcn/__init_fltk__.cc libinterp/dldfcn/__magick_read__.cc libinterp/dldfcn/__osmesa_print__.cc libinterp/dldfcn/__voronoi__.cc libinterp/dldfcn/audiodevinfo.cc libinterp/dldfcn/audioread.cc libinterp/dldfcn/ccolamd.cc libinterp/dldfcn/colamd.cc libinterp/dldfcn/convhulln.cc |
diffstat | 13 files changed, 137 insertions(+), 421 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__delaunayn__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__delaunayn__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -130,10 +130,7 @@ options += tmp(i) + " "; } else - { - error ("__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty"); - return retval; - } + error ("__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty"); } if (n > dim + 1) @@ -160,10 +157,7 @@ if (outfile) frame.add_fcn (close_fcn, outfile); else - { - error ("__delaunayn__: unable to create temporary file for output"); - return retval; - } + error ("__delaunayn__: unable to create temporary file for output"); int exitcode = qh_new_qhull (dim, n, pt_array, ismalloc, flags, outfile, errfile); @@ -184,11 +178,7 @@ // Double check. Non-simplicial facets will cause segfault below if (! facet->simplicial) - { - error ("__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options"); - exitcode = 1; - break; - } + error ("__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options"); } if (! exitcode) @@ -237,7 +227,9 @@ } #else + error ("__delaunayn__: not available in this version of Octave"); + #endif return retval;
--- a/libinterp/dldfcn/__eigs__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__eigs__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -214,16 +214,10 @@ eigs_fcn = args(0).function_value (); if (!eigs_fcn) - { - error ("eigs: unknown function"); - return retval; - } + error ("eigs: unknown function"); if (nargin < 2) - { - error ("eigs: incorrect number of arguments"); - return retval; - } + error ("eigs: incorrect number of arguments"); else { n = args(1).nint_value (); @@ -365,10 +359,7 @@ } if (nargin > (4+arg_offset)) - { - error ("eigs: incorrect number of arguments"); - return retval; - } + error ("eigs: incorrect number of arguments"); // Test undeclared (no issym) matrix inputs for symmetry if (!sym_tested && !have_a_fun) @@ -588,6 +579,7 @@ if (! fcn_name.empty ()) clear_function (fcn_name); + #else error ("eigs: not available in this version of Octave"); #endif
--- a/libinterp/dldfcn/__fltk_uigetfile__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__fltk_uigetfile__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -136,10 +136,15 @@ Fl::flush (); return retval; + #else + error ("__fltk_uigetfile__: not available without OpenGL and FLTK libraries"); - return octave_value (); + + return octave_value_list (); + #endif + } /*
--- a/libinterp/dldfcn/__glpk__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__glpk__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -309,10 +309,7 @@ if (! tmp.is_empty ()) \ VAL = tmp.xscalar_value ("glpk: invalid value in PARAM" NAME); \ else \ - { \ - error ("glpk: invalid value in PARAM" NAME); \ - return retval; \ - } \ + error ("glpk: invalid value in PARAM" NAME); \ } \ } \ while (0) @@ -327,10 +324,7 @@ if (! tmp.is_empty ()) \ VAL = tmp.xint_value ("glpk: invalid value in PARAM" NAME); \ else \ - { \ - error ("glpk: invalid value in PARAM" NAME); \ - return retval; \ - } \ + error ("glpk: invalid value in PARAM" NAME); \ } \ } \ while (0) @@ -376,10 +370,7 @@ a.resize (Anz+1, 0.0); if (Anc != mrowsc) - { - error ("__glpk__: invalid value of A"); - return retval; - } + error ("__glpk__: invalid value of A"); for (octave_idx_type j = 0; j < Anc; j++) for (octave_idx_type i = A.cidx (j); i < A.cidx (j+1); i++) @@ -426,10 +417,7 @@ Matrix LB = args(3).xmatrix_value ("__glpk__: invalid value of LB"); if (LB.numel () < mrowsc) - { - error ("__glpk__: invalid dimensions for LB"); - return retval; - } + error ("__glpk__: invalid dimensions for LB"); double *lb = LB.fortran_vec (); @@ -451,10 +439,7 @@ Matrix UB = args(4).xmatrix_value ("__glpk__: invalid value of UB"); if (UB.numel () < mrowsc) - { - error ("__glpk__: invalid dimensions for UB"); - return retval; - } + error ("__glpk__: invalid dimensions for UB"); double *ub = UB.fortran_vec (); @@ -514,37 +499,25 @@ par.msglev = 1; OCTAVE_GLPK_GET_INT_PARAM ("msglev", par.msglev); if (par.msglev < 0 || par.msglev > 3) - { - error ("__glpk__: PARAM.msglev must be 0 (no output) or 1 (error and warning messages only [default]) or 2 (normal output) or 3 (full output)"); - return retval; - } + error ("__glpk__: PARAM.msglev must be 0 (no output) or 1 (error and warning messages only [default]) or 2 (normal output) or 3 (full output)"); //-- scaling option volatile int scale = 16; OCTAVE_GLPK_GET_INT_PARAM ("scale", scale); if (scale < 0 || scale > 128) - { - error ("__glpk__: PARAM.scale must either be 128 (automatic selection of scaling options), or a bitwise or of: 1 (geometric mean scaling), 16 (equilibration scaling), 32 (round scale factors to power of two), 64 (skip if problem is well scaled"); - return retval; - } + error ("__glpk__: PARAM.scale must either be 128 (automatic selection of scaling options), or a bitwise or of: 1 (geometric mean scaling), 16 (equilibration scaling), 32 (round scale factors to power of two), 64 (skip if problem is well scaled"); //-- Dual simplex option par.dual = 1; OCTAVE_GLPK_GET_INT_PARAM ("dual", par.dual); if (par.dual < 1 || par.dual > 3) - { - error ("__glpk__: PARAM.dual must be 1 (use two-phase primal simplex [default]) or 2 (use two-phase dual simplex) or 3 (use two-phase dual simplex, and if it fails, switch to the primal simplex)"); - return retval; - } + error ("__glpk__: PARAM.dual must be 1 (use two-phase primal simplex [default]) or 2 (use two-phase dual simplex) or 3 (use two-phase dual simplex, and if it fails, switch to the primal simplex)"); //-- Pricing option par.price = 34; OCTAVE_GLPK_GET_INT_PARAM ("price", par.price); if (par.price != 17 && par.price != 34) - { - error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])"); - return retval; - } + error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])"); //-- Simplex iterations limit par.itlim = std::numeric_limits<int>::max (); @@ -558,46 +531,31 @@ par.branch = 4; OCTAVE_GLPK_GET_INT_PARAM ("branch", par.branch); if (par.branch < 1 || par.branch > 5) - { - error ("__glpk__: PARAM.branch must be 1 (first fractional variable) or 2 (last fractional variable) or 3 (most fractional variable) or 4 (heuristic by Driebeck and Tomlin [default]) or 5 (hybrid pseudocost heuristic)"); - return retval; - } + error ("__glpk__: PARAM.branch must be 1 (first fractional variable) or 2 (last fractional variable) or 3 (most fractional variable) or 4 (heuristic by Driebeck and Tomlin [default]) or 5 (hybrid pseudocost heuristic)"); //-- Backtracking heuristic option par.btrack = 4; OCTAVE_GLPK_GET_INT_PARAM ("btrack", par.btrack); if (par.btrack < 1 || par.btrack > 4) - { - error ("__glpk__: PARAM.btrack must be 1 (depth first search) or 2 (breadth first search) or 3 (best local bound) or 4 (best projection heuristic [default]"); - return retval; - } + error ("__glpk__: PARAM.btrack must be 1 (depth first search) or 2 (breadth first search) or 3 (best local bound) or 4 (best projection heuristic [default]"); //-- Presolver option par.presol = 1; OCTAVE_GLPK_GET_INT_PARAM ("presol", par.presol); if (par.presol < 0 || par.presol > 1) - { - error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])"); - return retval; - } + error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])"); //-- LPsolver option volatile int lpsolver = 1; OCTAVE_GLPK_GET_INT_PARAM ("lpsolver", lpsolver); if (lpsolver < 1 || lpsolver > 2) - { - error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)"); - return retval; - } + error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)"); //-- Ratio test option par.rtest = 34; OCTAVE_GLPK_GET_INT_PARAM ("rtest", par.rtest); if (par.rtest != 17 && par.rtest != 34) - { - error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])"); - return retval; - } + error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])"); par.tmlim = std::numeric_limits<int>::max (); OCTAVE_GLPK_GET_INT_PARAM ("tmlim", par.tmlim);
--- a/libinterp/dldfcn/__init_fltk__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__init_fltk__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -1776,11 +1776,7 @@ instance = new figure_manager (); if (! instance) - { - error ("unable to create figure_manager object!"); - - retval = false; - } + error ("unable to create figure_manager object!"); return retval; } @@ -2083,7 +2079,9 @@ if (istr >> ind) return ind; } + error ("figure_manager: could not recognize fltk index"); + return -1; } @@ -2104,7 +2102,9 @@ else return 0; } + error ("figure_manager: figure is not fltk"); + return -1; } @@ -2117,7 +2117,9 @@ dynamic_cast<figure::properties&> (fobj.get_properties ()); return figprops2idx (fp); } + error ("figure_manager: H (= %g) is not a figure", h); + return -1; }
--- a/libinterp/dldfcn/__magick_read__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__magick_read__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -669,7 +669,6 @@ default: error ("__magick_read__: unknown Magick++ image type"); - return retval; } retval(0) = img; @@ -795,7 +794,6 @@ // need to be ordered (this is a feature and even allows for // some frames to be read multiple times). error ("imread: index/frames specified are outside the number of images"); - return output; } } } @@ -815,7 +813,6 @@ { error ("imread: all frames must have the same size but frame %i is different", frameidx(frame) +1); - return output; } } } @@ -833,10 +830,7 @@ output = read_indexed_images<uint16NDArray> (imvec, frameidx, nargout, options); else - { - error ("imread: indexed images with depths greater than 16-bit are not supported"); - return output; - } + error ("imread: indexed images with depths greater than 16-bit are not supported"); } else @@ -850,10 +844,8 @@ else if (depth <= 32) output = read_images<FloatNDArray> (imvec, frameidx, nargout, options); else - { - error ("imread: reading of images with %i-bit depth is not supported", - depth); - } + error ("imread: reading of images with %i-bit depth is not supported", + depth); } #endif @@ -1082,11 +1074,8 @@ break; default: - { - // __imwrite should have already filtered this cases - error ("__magick_write__: wrong size on 3rd dimension"); - return; - } + // __imwrite should have already filtered this cases + error ("__magick_write__: wrong size on 3rd dimension"); } // We will be passing the values as integers with depth as specified @@ -1315,11 +1304,9 @@ } default: - { - error ("__magick_write__: unrecognized Magick::ImageType"); - return; - } + error ("__magick_write__: unrecognized Magick::ImageType"); } + return; } @@ -1461,10 +1448,7 @@ encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha); } else - { - error ("__magick_write__: image type not supported"); - return retval; - } + error ("__magick_write__: image type not supported"); } else { @@ -1478,10 +1462,7 @@ encode_indexed_images<uint16NDArray> (imvec, img.uint16_array_value (), cmap); else - { - error ("__magick_write__: indexed image must be uint8, uint16 or float."); - return retval; - } + error ("__magick_write__: indexed image must be uint8, uint16 or float."); } static std::map<std::string, octave_idx_type> disposal_methods = init_reverse_disposal_methods (); @@ -1614,7 +1595,6 @@ catch (Magick::Exception& e) { error ("Magick++ exception: %s", e.what ()); - return retval; } static const char *fields[] = {"rows", "columns", "format", 0}; @@ -1913,11 +1893,8 @@ template_info.setfield ("FileSize", octave_value (fs.size ())); } else - { - error ("imfinfo: error reading '%s': %s", - filename.c_str (), fs.error ().c_str ()); - return retval; - } + error ("imfinfo: error reading '%s': %s", filename.c_str (), + fs.error ().c_str ()); for (octave_idx_type frame = 0; frame < nFrames; frame++) {
--- a/libinterp/dldfcn/__osmesa_print__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__osmesa_print__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -101,24 +101,17 @@ if (nargin == 3) { if (! (args(1).is_string () && args(2).is_string ())) - { - error ("__osmesa_print__: FILE and TERM must be strings"); - return retval; - } + error ("__osmesa_print__: FILE and TERM must be strings"); #ifndef HAVE_GL2PS_H error ("__osmesa_print__: Octave has been compiled without gl2ps"); - return retval; #endif } int h = args(0).double_value (); graphics_object fobj = gh_manager::get_object (h); if (! (fobj && fobj.isa ("figure"))) - { - error ("__osmesa_print__: H must be a valid figure handle"); - return retval; - } + error ("__osmesa_print__: H must be a valid figure handle"); figure::properties& fp = dynamic_cast<figure::properties&> (fobj.get_properties ()); @@ -132,20 +125,14 @@ // Create an RGBA-mode context, specify Z=16, stencil=0, accum=0 sizes OSMesaContext ctx = OSMesaCreateContextExt (OSMESA_RGBA, 16, 0, 0, NULL); if (! ctx) - { - error ("__osmesa_print__: OSMesaCreateContext failed!\n"); - return retval; - } + error ("__osmesa_print__: OSMesaCreateContext failed!\n"); // Allocate the image buffer OCTAVE_LOCAL_BUFFER (GLubyte, buffer, 4 * Width * Height); // Bind the buffer to the context and make it current if (! OSMesaMakeCurrent (ctx, buffer, GL_UNSIGNED_BYTE, Width, Height)) - { - error ("__osmesa_print__: OSMesaMakeCurrent failed!\n"); - return retval; - } + error ("__osmesa_print__: OSMesaMakeCurrent failed!\n"); // Test for a bug in OSMesa with version < 9.0 //
--- a/libinterp/dldfcn/__voronoi__.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/__voronoi__.cc Tue Dec 08 14:20:05 2015 -0500 @@ -68,10 +68,7 @@ int maxval = std::numeric_limits<int>::max (); if (dim > maxval || n > maxval) - { - error ("%s: dimension too large for Qhull", who); - return false; - } + error ("%s: dimension too large for Qhull", who); } return true; @@ -131,11 +128,8 @@ options += " " + tmp(i); } else - { - error ("%s: OPTIONS must be a string, cell array of strings, or empty", - caller.c_str ()); - return retval; - } + error ("%s: OPTIONS must be a string, cell array of strings, or empty", + caller.c_str ()); } boolT ismalloc = false; @@ -153,10 +147,7 @@ if (outfile) frame.add_fcn (close_fcn, outfile); else - { - error ("__voronoi__: unable to create temporary file for output"); - return retval; - } + error ("__voronoi__: unable to create temporary file for output"); // qh_new_qhull command and points arguments are not const...
--- a/libinterp/dldfcn/audiodevinfo.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/audiodevinfo.cc Tue Dec 08 14:20:05 2015 -0500 @@ -114,18 +114,12 @@ PaError err = Pa_Initialize (); if (err != paNoError) - { - error ("audiodevinfo: PortAudio initialization failed"); - return retval; - } + error ("audiodevinfo: PortAudio initialization failed"); int num_devices = Pa_GetDeviceCount (); if (num_devices < 0) - { - error ("audiodevinfo: no audio device found"); - return retval; - } + error ("audiodevinfo: no audio device found"); octave_idx_type numinput = 0, numoutput = 0; for (int i = 0; i < num_devices; i++) @@ -211,10 +205,7 @@ else if (args(0).int_value () == 1) retval = numinput; else - { - error ("audiodevinfo: please specify 0 for output and 1 for input devices"); - return retval; - } + error ("audiodevinfo: please specify 0 for output and 1 for input devices"); } // Return device name when given id or id when given device name. else if (nargin == 2) @@ -248,10 +239,7 @@ } } else - { - error ("audiodevinfo: please specify 0 for output and 1 for input devices"); - return retval; - } + error ("audiodevinfo: please specify 0 for output and 1 for input devices"); } else { @@ -280,11 +268,9 @@ } } else - { - error ("audiodevinfo: please specify 0 for output and 1 for input devices"); - return retval; - } + error ("audiodevinfo: please specify 0 for output and 1 for input devices"); } + if (! found) error ("audiodevinfo: no device meeting the specified criteria found"); } @@ -310,10 +296,7 @@ if (format != 0) stream_parameters.sampleFormat = format; else - { - error ("audiodevinfo: no such bits per sample format"); - return retval; - } + error ("audiodevinfo: no such bits per sample format"); const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i); @@ -372,18 +355,12 @@ if (format != 0) stream_parameters.sampleFormat = format; else - { - error ("audiodevinfo: no such bits per sample format"); - return retval; - } + error ("audiodevinfo: no such bits per sample format"); const PaDeviceInfo *device_info = Pa_GetDeviceInfo (id); if (! device_info) - { - error ("audiodevinfo: invalid audio device ID = %d", id); - return retval; - } + error ("audiodevinfo: invalid audio device ID = %d", id); stream_parameters.suggestedLatency = device_info->defaultLowInputLatency; @@ -418,17 +395,13 @@ } } else - { - error ("audiodevinfo: please specify 0 for output and 1 for input devices"); - return retval; - } + error ("audiodevinfo: please specify 0 for output and 1 for input devices"); + retval = 0; } else - { - error ("audiodevinfo: wrong number of arguments"); - return retval; - } + error ("audiodevinfo: wrong number of arguments"); + #else error ("portaudio not found on your system and thus audio functionality is not present"); @@ -562,29 +535,20 @@ audioplayer *player = static_cast<audioplayer *> (data); if (! player) - { - error ("audio player callback function called without player"); - return paAbort; - } + error ("audio player callback function called without player"); octave_value_list retval = feval (player->octave_callback_function, ovl (static_cast<double> (frames)), 1); if (retval.length () < 2) - { - error ("audio player callback function failed"); - return paAbort; - } + error ("audio player callback function failed"); const Matrix sound = retval(0).matrix_value (); int return_status = retval(1).int_value (); if (frames - sound.rows () != 0 || sound.columns () < 1 || sound.columns () > 2) - { - error ("audio player callback function failed"); - return paAbort; - } + error ("audio player callback function failed"); // Don't multiply the audio data by scale_factor here. Although it // does move the operation outside of the loops below, it also causes @@ -662,7 +626,6 @@ default: error ("invalid player bit depth in callback function"); - break; } return return_status; @@ -676,10 +639,7 @@ audioplayer *player = static_cast<audioplayer *> (data); if (! player) - { - error ("audio player callback function called without player"); - return paAbort; - } + error ("audio player callback function called without player"); // Don't multiply the audio data by scale_factor here. Although it // would move the operation outside of the loops below, it also causes @@ -785,7 +745,6 @@ default: error ("invalid player bit depth in callback function"); - break; } } else if (player->get_type () == TYPE_INT8) @@ -889,16 +848,10 @@ audioplayer::init_fn (void) { if (Pa_Initialize () != paNoError) - { - error ("audioplayer: initialization error!"); - return; - } + error ("audioplayer: initialization error!"); if (Pa_GetDeviceCount () < 1) - { - error ("audioplayer: no audio devices found or available!"); - return; - } + error ("audioplayer: no audio devices found or available!"); int device = get_id (); @@ -931,16 +884,10 @@ // RowVector *sound_l = get_left (); if (Pa_Initialize () != paNoError) - { - error ("audioplayer: initialization error!"); - return; - } + error ("audioplayer: initialization error!"); if (Pa_GetDeviceCount () < 1) - { - error ("audioplayer: no audio devices found or available!"); - return; - } + error ("audioplayer: no audio devices found or available!"); int device = get_id (); @@ -1144,17 +1091,11 @@ err = Pa_OpenStream (&stream, 0, &(output_parameters), get_fs (), buffer_size, paClipOff, 0, 0); if (err != paNoError) - { - error ("audioplayer: unable to open audio playback stream"); - return; - } + error ("audioplayer: unable to open audio playback stream"); err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audioplayer: unable to start start audio playback stream"); - return; - } + error ("audioplayer: unable to start start audio playback stream"); unsigned int start, end; start = get_sample_number (); @@ -1195,17 +1136,11 @@ portaudio_play_callback, this); if (err != paNoError) - { - error ("audioplayer: failed to open audio playback stream"); - return; - } + error ("audioplayer: failed to open audio playback stream"); err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audioplayer: failed to start audio playback stream"); - return; - } + error ("audioplayer: failed to start audio playback stream"); } void @@ -1217,10 +1152,7 @@ PaError err; err = Pa_StopStream (stream); if (err != paNoError) - { - error ("audiorecorder: failed to stop audio recording stream"); - return; - } + error ("audiorecorder: failed to stop audio recording stream"); } void @@ -1232,10 +1164,7 @@ PaError err; err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audiorecorder: failed to start audio recording stream"); - return; - } + error ("audiorecorder: failed to start audio recording stream"); } PaStream * @@ -1257,18 +1186,12 @@ { err = Pa_AbortStream (get_stream ()); if (err != paNoError) - { - error ("audioplayer: failed to stop audio playback stream"); - return; - } + error ("audioplayer: failed to stop audio playback stream"); } err = Pa_CloseStream (get_stream ()); if (err != paNoError) - { - error ("audioplayer: failed to close audio playback stream"); - return; - } + error ("audioplayer: failed to close audio playback stream"); stream = 0; } @@ -1282,10 +1205,7 @@ PaError err; err = Pa_IsStreamActive (stream); if (err != 0 && err != 1) - { - error ("audiorecorder: checking stream activity status failed"); - return false; - } + error ("audiorecorder: checking stream activity status failed"); return (err == 1); } @@ -1372,10 +1292,7 @@ audiorecorder *recorder = static_cast<audiorecorder *> (data); if (! recorder) - { - error ("audio recorder callback function called without player"); - return paAbort; - } + error ("audio recorder callback function called without player"); int channels = recorder->get_channels (); @@ -1457,10 +1374,7 @@ audiorecorder *recorder = static_cast<audiorecorder *> (data); if (! recorder) - { - error ("audio recorder callback function called without player"); - return paAbort; - } + error ("audio recorder callback function called without player"); int channels = recorder->get_channels (); @@ -1569,16 +1483,10 @@ audiorecorder::init (void) { if (Pa_Initialize () != paNoError) - { - error ("audiorecorder: initialization error!"); - return; - } + error ("audiorecorder: initialization error!"); if (Pa_GetDeviceCount () < 1) - { - error ("audiorecorder: no audio devices found or available!"); - return; - } + error ("audiorecorder: no audio devices found or available!"); int device = get_id (); @@ -1752,10 +1660,7 @@ PaError err; err = Pa_IsStreamActive (stream); if (err != 0 && err != 1) - { - error ("audiorecorder: checking stream activity status failed"); - return false; - } + error ("audiorecorder: checking stream activity status failed"); return (err == 1); } @@ -1785,16 +1690,11 @@ portaudio_record_callback, this); } if (err != paNoError) - { - error ("audiorecorder: unable to open audio recording stream"); - return; - } + error ("audiorecorder: unable to open audio recording stream"); + err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audiorecorder: unable to start audio recording stream"); - return; - } + error ("audiorecorder: unable to start audio recording stream"); } void @@ -1813,17 +1713,11 @@ err = Pa_OpenStream (&stream, &(input_parameters), 0, get_fs (), buffer_size, paClipOff, 0, this); if (err != paNoError) - { - error ("audiorecorder: unable to open audio recording stream"); - return; - } + error ("audiorecorder: unable to open audio recording stream"); err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audiorecorder: unable to start audio recording stream"); - return; - } + error ("audiorecorder: unable to start audio recording stream"); unsigned int frames = seconds * get_fs (); @@ -1852,10 +1746,7 @@ PaError err; err = Pa_StopStream (stream); if (err != paNoError) - { - error ("audiorecorder: unable to stop audio recording stream"); - return; - } + error ("audiorecorder: unable to stop audio recording stream"); } void @@ -1867,10 +1758,7 @@ PaError err; err = Pa_StartStream (stream); if (err != paNoError) - { - error ("audiorecorder: unable to start audio recording stream"); - return; - } + error ("audiorecorder: unable to start audio recording stream"); } void @@ -1884,18 +1772,12 @@ { err = Pa_AbortStream (get_stream ()); if (err != paNoError) - { - error ("audioplayer: unable to stop audio playback stream"); - return; - } + error ("audioplayer: unable to stop audio playback stream"); } err = Pa_CloseStream (stream); if (err != paNoError) - { - error ("audiorecorder: unable to close audio recording stream"); - return; - } + error ("audiorecorder: unable to close audio recording stream"); set_sample_number (0); reset_end_sample (); @@ -1942,13 +1824,7 @@ || args(0).is_inline_function ()); if (is_function) - { - error ("audioplayer: callbacks not yet implemented"); - return retval; - - // recorder->octave_callback_function = args(0).function_value (); - // offset = 1; - } + error ("audioplayer: callbacks not yet implemented"); } switch (nargin - offset) @@ -2539,12 +2415,7 @@ || args(0).is_inline_function ()); if (is_function) - { - error ("audioplayer: callbacks not yet implemented"); - return retval; - - // recorder->set_y (args(0).function_value ()); - } + error ("audioplayer: callbacks not yet implemented"); else recorder->set_y (args(0)); @@ -2912,10 +2783,7 @@ if (start > player->get_total_samples () || start > end || end > player->get_total_samples ()) - { - error ("audioplayer: invalid range specified for playback"); - return retval; - } + error ("audioplayer: invalid range specified for playback"); player->set_sample_number (start); player->set_end_sample (end); @@ -2925,10 +2793,7 @@ unsigned int start = args(1).int_value () - 1; if (start > player->get_total_samples ()) - { - error ("audioplayer: invalid range specified for playback"); - return retval; - } + error ("audioplayer: invalid range specified for playback"); player->set_sample_number (start); } @@ -2979,10 +2844,7 @@ if (start > player->get_total_samples () || start > end || end > player->get_total_samples ()) - { - error ("audioplayer: invalid range specified for playback"); - return retval; - } + error ("audioplayer: invalid range specified for playback"); player->set_sample_number (start); player->set_end_sample (end); @@ -2992,10 +2854,7 @@ unsigned int start = args(1).int_value () - 1; if (start > player->get_total_samples ()) - { - error ("audioplayer: invalid range specified for playback"); - return retval; - } + error ("audioplayer: invalid range specified for playback"); player->set_sample_number (start); }
--- a/libinterp/dldfcn/audioread.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/audioread.cc Tue Dec 08 14:20:05 2015 -0500 @@ -86,10 +86,7 @@ SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info); if (! file) - { - error ("audioread: failed to open input file %s", filename.c_str ()); - return retval; - } + error ("audioread: failed to open input file %s", filename.c_str ()); unwind_protect frame; @@ -107,20 +104,14 @@ RowVector range = args(1).row_vector_value (); if (range.numel () != 2) - { - error ("audioread: invalid specification for range of frames"); - return retval; - } + error ("audioread: invalid specification for range of frames"); double dstart = xisinf (range(0)) ? info.frames : range(0); double dend = xisinf (range(1)) ? info.frames : range(1); if (dstart < 1 || dstart > dend || dend > info.frames || D_NINT (dstart) != dstart || D_NINT (dend) != dend) - { - error ("audioread: invalid specification for range of frames"); - return retval; - } + error ("audioread: invalid specification for range of frames"); start = dstart - 1; end = dend; @@ -378,10 +369,7 @@ else if (bits == 32) info.format |= SF_FORMAT_PCM_32; else - { - error ("audiowrite: wrong number of bits specified"); - return retval; - } + error ("audiowrite: wrong number of bits specified"); } else if (args(i).string_value () == "BitRate") ; @@ -396,19 +384,13 @@ else if (args(i).string_value () == "Comment") comment = args(i + 1).string_value (); else - { - error ("audiowrite: wrong argument name"); - return retval; - } + error ("audiowrite: wrong argument name"); } SNDFILE *file = sf_open (filename.c_str (), SFM_WRITE, &info); if (! file) - { - error ("audiowrite: failed to open output file %s", filename.c_str ()); - return retval; - } + error ("audiowrite: failed to open output file %s", filename.c_str ()); unwind_protect frame; @@ -437,11 +419,8 @@ sf_count_t items_written = sf_write_float (file, data+offset, chunk_size); if (items_written != chunk_size) - { - error ("audiowrite: write failed, wrote %ld of %ld items\n", - items_written, chunk_size); - return retval; - } + error ("audiowrite: write failed, wrote %ld of %ld items\n", + items_written, chunk_size); total_items_written += items_written; offset += chunk_size; @@ -476,10 +455,7 @@ SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info); if (! file) - { - error ("audioinfo: failed to open file %s", filename.c_str ()); - return retval; - } + error ("audioinfo: failed to open file %s", filename.c_str ()); unwind_protect frame;
--- a/libinterp/dldfcn/ccolamd.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/ccolamd.cc Tue Dec 08 14:20:05 2015 -0500 @@ -287,8 +287,8 @@ knobs, stats, cmember)) { CCOLAMD_NAME (_report) (stats) ; + error ("ccolamd: internal error!"); - return retval; } } else @@ -297,8 +297,8 @@ if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats, 0)) { CCOLAMD_NAME (_report) (stats) ; + error ("ccolamd: internal error!"); - return retval; } } @@ -499,10 +499,7 @@ } if (n_row != n_col) - { - error ("csymamd: matrix S must be square"); - return retval; - } + error ("csymamd: matrix S must be square"); // Allocate workspace for symamd OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1); @@ -523,8 +520,8 @@ &calloc, &free, cmember, -1)) { CSYMAMD_NAME (_report) (stats) ; + error ("csymamd: internal error!") ; - return retval; } } else @@ -533,8 +530,8 @@ &calloc, &free, 0, -1)) { CSYMAMD_NAME (_report) (stats) ; + error ("csymamd: internal error!") ; - return retval; } }
--- a/libinterp/dldfcn/colamd.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/colamd.cc Tue Dec 08 14:20:05 2015 -0500 @@ -393,8 +393,8 @@ if (! COLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats)) { COLAMD_NAME (_report) (stats) ; + error ("colamd: internal error!"); - return retval; } // column elimination tree post-ordering (reuse variables) @@ -582,10 +582,7 @@ } if (n_row != n_col) - { - error ("symamd: matrix S must be square"); - return retval; - } + error ("symamd: matrix S must be square"); // Allocate workspace for symamd OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1); @@ -594,8 +591,8 @@ knobs, stats, &calloc, &free)) { SYMAMD_NAME (_report) (stats) ; + error ("symamd: internal error!") ; - return retval; } // column elimination tree post-ordering @@ -666,17 +663,15 @@ if (nargout > 2 || nargin < 1 || nargin > 2) print_usage (); - octave_idx_type n_row, n_col; - octave_idx_type *ridx, *cidx; - bool is_sym = true; - SparseMatrix sm; - SparseComplexMatrix scm; + octave_idx_type n_row = 0, n_col = 0; + octave_idx_type *ridx = 0, *cidx = 0; if (args(0).is_sparse_type ()) { if (args(0).is_complex_type ()) { - scm = args(0).sparse_complex_matrix_value (); + SparseComplexMatrix scm = args(0).sparse_complex_matrix_value (); + n_row = scm.rows (); n_col = scm.cols (); ridx = scm.xridx (); @@ -684,7 +679,8 @@ } else { - sm = args(0).sparse_matrix_value (); + SparseMatrix sm = args(0).sparse_matrix_value (); + n_row = sm.rows (); n_col = sm.cols (); ridx = sm.xridx (); @@ -693,10 +689,9 @@ } else - { - error ("etree: S must be a sparse matrix"); - return retval; - } + error ("etree: S must be a sparse matrix"); + + bool is_sym = true; if (nargin == 2) { @@ -711,10 +706,7 @@ if (is_sym) { if (n_row != n_col) - { - error ("etree: S is marked as symmetric, but is not square"); - return retval; - } + error ("etree: S is marked as symmetric, but is not square"); symetree (ridx, cidx, etree, 0, n_col); }
--- a/libinterp/dldfcn/convhulln.cc Tue Dec 08 12:34:23 2015 -0500 +++ b/libinterp/dldfcn/convhulln.cc Tue Dec 08 14:20:05 2015 -0500 @@ -63,10 +63,7 @@ int maxval = std::numeric_limits<int>::max (); if (dim > maxval || n > maxval) - { - error ("%s: dimension too large for Qhull", who); - return false; - } + error ("%s: dimension too large for Qhull", who); } return true; @@ -147,10 +144,7 @@ options += " " + tmp(i); } else - { - error ("convhulln: OPTIONS must be a string, cell array of strings, or empty"); - return retval; - } + error ("convhulln: OPTIONS must be a string, cell array of strings, or empty"); } boolT ismalloc = false; @@ -168,10 +162,7 @@ if (outfile) frame.add_fcn (close_fcn, outfile); else - { - error ("convhulln: unable to create temporary file for output"); - return retval; - } + error ("convhulln: unable to create temporary file for output"); // qh_new_qhull command and points arguments are not const... @@ -204,11 +195,8 @@ nonsimp_seen = true; if (cmd.find ("QJ") != std::string::npos) - { - // Should never happen with QJ. - error ("convhulln: qhull failed: option 'QJ' returned non-simplicial facet"); - return retval; - } + // Should never happen with QJ. + error ("convhulln: qhull failed: option 'QJ' returned non-simplicial facet"); } if (dim == 3)