[beast: 26/29] BSE: fix Bse::error checks



commit 643544af2e3356b78d67ab47ed13518260c24bc8
Author: Tim Janik <timj gnu org>
Date:   Mon Mar 7 01:37:34 2016 +0100

    BSE: fix Bse::error checks
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bsebus.cc               |   10 +++++-----
 bse/bsedatahandle-flac.cc   |    2 +-
 bse/bsedevice.cc            |   10 +++++-----
 bse/bseeditablesample.proc  |    2 +-
 bse/bseitem.cc              |    4 ++--
 bse/bseloader-mad.cc        |    2 +-
 bse/bseloader-wav.cc        |    2 +-
 bse/bseloader.cc            |    8 ++++----
 bse/bseproject.cc           |    8 ++++----
 bse/bseserver.cc            |    6 +++---
 bse/bsewave.cc              |    8 ++++----
 bse/bsewaverepo.proc        |    2 +-
 bse/gsldatahandle-mad.cc    |    4 ++--
 bse/gsldatahandle-vorbis.cc |    2 +-
 bse/gsldatahandle.cc        |    3 +--
 15 files changed, 36 insertions(+), 37 deletions(-)
---
diff --git a/bse/bsebus.cc b/bse/bsebus.cc
index 905e047..4a2ec3a 100644
--- a/bse/bsebus.cc
+++ b/bse/bsebus.cc
@@ -686,7 +686,7 @@ bse_bus_connect_unchecked (BseBus  *self,
       BSE_ITEM (osource)->parent != BSE_ITEM (self)->parent)    /* restrict to siblings */
     return Bse::Error::SOURCE_PARENT_MISMATCH;
   Bse::Error error = bse_source_set_input (self->summation, 0, osource, 0);
-  if (!error)
+  if (error == 0)
     {
       bse_source_must_set_input (self->summation, 1, osource, 1);
       self->inputs = sfi_ring_append (self->inputs, trackbus);
@@ -967,7 +967,7 @@ BusImpl::connect_bus (BusIface &busi)
     return Error::SOURCE_PARENT_MISMATCH;
 
   Error error = bse_bus_connect (self, bus.as<BseItem*>());
-  if (!error)
+  if (error == 0)
     {
       // an undo lambda is needed for wrapping object argument references
       UndoDescriptor<BusImpl> bus_descriptor = undo_descriptor (bus);
@@ -988,7 +988,7 @@ BusImpl::connect_track (TrackIface &tracki)
     return Error::SOURCE_PARENT_MISMATCH;
 
   Error error = bse_bus_connect (self, track.as<BseItem*>());
-  if (!error)
+  if (error == 0)
     {
       // an undo lambda is needed for wrapping object argument references
       UndoDescriptor<TrackImpl> track_descriptor = undo_descriptor (track);
@@ -1006,7 +1006,7 @@ BusImpl::disconnect_bus (BusIface &busi)
   BseBus *self = as<BseBus*>();
   BusImpl &bus = dynamic_cast<BusImpl&> (busi);
   Error error = bse_bus_disconnect (self, busi.as<BseItem*>());
-  if (!error)
+  if (error == 0)
     {
       // an undo lambda is needed for wrapping object argument references
       UndoDescriptor<BusImpl> bus_descriptor = undo_descriptor (bus);
@@ -1024,7 +1024,7 @@ BusImpl::disconnect_track (TrackIface &tracki)
   BseBus *self = as<BseBus*>();
   TrackImpl &track = dynamic_cast<TrackImpl&> (tracki);
   Error error = bse_bus_disconnect (self, tracki.as<BseItem*>());
-  if (!error)
+  if (error == 0)
     {
       // an undo lambda is needed for wrapping object argument references
       UndoDescriptor<TrackImpl> track_descriptor = undo_descriptor (track);
diff --git a/bse/bsedatahandle-flac.cc b/bse/bsedatahandle-flac.cc
index 0a90e61..16c17c2 100644
--- a/bse/bsedatahandle-flac.cc
+++ b/bse/bsedatahandle-flac.cc
@@ -358,7 +358,7 @@ bse_data_handle_new_flac_zoffset (const char *file_name,
 
   /* figure out mix_freq, n_channels */
   Bse::Error error = gsl_data_handle_open (dhandle);
-  if (!error)
+  if (error == 0)
     {
       if (n_channels_p)
         *n_channels_p = dhandle->setup.n_channels;
diff --git a/bse/bsedevice.cc b/bse/bsedevice.cc
index 427d1f1..9f6784a 100644
--- a/bse/bsedevice.cc
+++ b/bse/bsedevice.cc
@@ -56,7 +56,7 @@ device_open_args (BseDevice      *self,
                                              n, (const char**) args);
   g_strfreev (args);
 
-  if (!error)
+  if (error == 0)
     {
       assert_return (BSE_DEVICE_OPEN (self), Bse::Error::INTERNAL);
       assert_return (self->open_device_name != NULL, Bse::Error::INTERNAL); /* bse_device_set_opened() was 
not called */
@@ -68,8 +68,8 @@ device_open_args (BseDevice      *self,
   else
     assert_return (!BSE_DEVICE_OPEN (self), Bse::Error::INTERNAL);
 
-  if (!error && ((need_readable && !BSE_DEVICE_READABLE (self)) ||
-                 (need_writable && !BSE_DEVICE_WRITABLE (self))))
+  if (error == 0 && ((need_readable && !BSE_DEVICE_READABLE (self)) ||
+                     (need_writable && !BSE_DEVICE_WRITABLE (self))))
     {
       bse_device_close (self);
       error = Bse::Error::DEVICE_NOT_AVAILABLE;
@@ -98,7 +98,7 @@ bse_device_open (BseDevice      *self,
           if (!entry->device_error)
             {
               error = device_open_args (self, need_readable, need_writable, entry->device_args);
-              if (!error)
+              if (error == 0)
                 break;
             }
         }
@@ -456,7 +456,7 @@ bse_device_open_best (GType           base_type,
           Bse::Error error = bse_device_open (device, need_readable, need_writable, args ? args + 1 : NULL);
           if (errorp)
             *errorp = error;
-          if (!error)
+          if (error == 0)
             break;
           g_object_unref (device);
           device = NULL;
diff --git a/bse/bseeditablesample.proc b/bse/bseeditablesample.proc
index 9a8c4c4..ecbd7a2 100644
--- a/bse/bseeditablesample.proc
+++ b/bse/bseeditablesample.proc
@@ -39,7 +39,7 @@ METHOD (BseEditableSample, open) {
   else
     {
       error = gsl_wave_chunk_open (esample->wchunk);
-      if (!error)
+      if (error == 0)
        esample->open_count++;
     }
 
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 6a0f964..c49d4a0 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -894,7 +894,7 @@ undo_call_proc (BseUndoStep  *ustep,
       if (proc->n_out_pspecs)
         {
           /* check returned error if any */
-          if (G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[0]) == BSE_TYPE_ERROR_TYPE && !error)
+          if (G_PARAM_SPEC_VALUE_TYPE (proc->out_pspecs[0]) == BSE_TYPE_ERROR_TYPE && error == 0)
             error = Bse::Error (g_value_get_enum (&ovalue));
           g_value_unset (&ovalue);
         }
@@ -950,7 +950,7 @@ bse_item_push_undo_proc_valist (void        *item,
 
   /* collect procedure args */
   error = bse_procedure_collect_input_args (proc, ivalues + 0, var_args, ivalues);
-  if (!error)
+  if (error == 0)
     {
       BseUndoStep *ustep = bse_undo_step_new (undo_call_proc, unde_free_proc, 3);
       /* convert values for undo */
diff --git a/bse/bseloader-mad.cc b/bse/bseloader-mad.cc
index 618bfa1..8481724 100644
--- a/bse/bseloader-mad.cc
+++ b/bse/bseloader-mad.cc
@@ -109,7 +109,7 @@ mad_create_chunk_handle (void         *data,
       dhandle = gsl_data_handle_new_add_xinfos (dhandle, wdsc->chunks[0].xinfos);
       gsl_data_handle_unref (tmp_handle);
     }
-  if (!dhandle && !*error_p)
+  if (!dhandle && 0 == *error_p)
     *error_p = Bse::Error::FILE_OPEN_FAILED;
   return dhandle;
 }
diff --git a/bse/bseloader-wav.cc b/bse/bseloader-wav.cc
index 864efc6..28f6dc1 100644
--- a/bse/bseloader-wav.cc
+++ b/bse/bseloader-wav.cc
@@ -324,7 +324,7 @@ wav_load_wave_dsc (void            *data,
   data_width = (fmt_header.bit_per_sample + 7) / 8;
   *error_p = wav_read_data_header (fi->fd, &data_header, data_width * fmt_header.n_channels);
   data_offset = lseek (fi->fd, 0, SEEK_CUR);
-  if (data_offset < ssize_t (sizeof (WavHeader)) && !*error_p)
+  if (data_offset < ssize_t (sizeof (WavHeader)) && 0 == *error_p)
     {
       LDEBUG ("failed to seek to start of data");
       *error_p = gsl_error_from_errno (errno, Bse::Error::IO);
diff --git a/bse/bseloader.cc b/bse/bseloader.cc
index e4b89cc..5bf152c 100644
--- a/bse/bseloader.cc
+++ b/bse/bseloader.cc
@@ -151,7 +151,7 @@ bse_wave_file_info_load (const char   *file_name,
          loader->free_file_info (loader->data, finfo);
          finfo = NULL;
        }
-      if (!finfo && !error)
+      if (!finfo && error == 0)
        error = Bse::Error::FILE_EMPTY; /* FIXME: try next loader */
       if (finfo)
        {
@@ -181,7 +181,7 @@ bse_wave_file_info_load (const char   *file_name,
     {
       /* try to provide apropriate error code */
       error = gsl_file_check (file_name, "rf");
-      if (!error)
+      if (error == 0)
        error = Bse::Error::FORMAT_UNKNOWN;
     }
 
@@ -256,7 +256,7 @@ bse_wave_dsc_load (BseWaveFileInfo *wave_file_info,
       loader->free_wave_dsc (loader->data, wdsc);
       wdsc = NULL;
     }
-  if (!wdsc && !error)
+  if (!wdsc && error == 0)
     error = Bse::Error::FILE_EMPTY;
   if (wdsc)
     {
@@ -322,7 +322,7 @@ bse_wave_handle_create (BseWaveDsc   *wave_dsc,
       gsl_data_handle_unref (dhandle);
       dhandle = NULL;
     }
-  if (!dhandle && !error)
+  if (!dhandle && error == 0)
     error = Bse::Error::FORMAT_INVALID;
 
   if (error_p)
diff --git a/bse/bseproject.cc b/bse/bseproject.cc
index f821907..2b6570c 100644
--- a/bse/bseproject.cc
+++ b/bse/bseproject.cc
@@ -646,7 +646,7 @@ bse_project_create_intern_synth (BseProject  *self,
       strap.max_items = 1;
       strap.base_type = check_type;
       strap.items = NULL;
-      if (!error)
+      if (error == 0)
        error = bse_project_restore (self, storage);
       bse_storage_reset (storage);
       g_object_unref (storage);
@@ -947,7 +947,7 @@ ProjectImpl::play ()
   BseProject *self = as<BseProject*>();
   BseProjectState state_before = self->state;
   Bse::Error error = bse_project_activate (self);
-  if (!error)
+  if (error == 0)
     {
       if (self->state == BSE_PROJECT_PLAYING)
         bse_project_stop_playback (self);
@@ -1138,7 +1138,7 @@ ProjectImpl::import_midi_file (const String &file_name)
   BseProject *self = as<BseProject*>();
   Bse::Error error = Bse::Error::NONE;
   BseMidiFile *smf = bse_midi_file_load (file_name.c_str(), &error);
-  if (!error)
+  if (error == 0)
     {
       BseUndoStack *ustack = bse_item_undo_open (self, "import-midi-file");
       BseSong *song = bse_project_get_song (self);
@@ -1166,7 +1166,7 @@ ProjectImpl::restore_from_file (const String &file_name)
     {
       BseStorage *storage = (BseStorage*) bse_object_new (BSE_TYPE_STORAGE, NULL);
       error = bse_storage_input_file (storage, file_name.c_str());
-      if (!error)
+      if (error == 0)
         error = bse_project_restore (self, storage);
       bse_storage_reset (storage);
       g_object_unref (storage);
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index 4e9a333..600c539 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -538,7 +538,7 @@ bse_server_open_devices (BseServer *self)
   guint block_size, latency = BSE_GCONFIG (synth_latency), mix_freq = BSE_GCONFIG (synth_mixing_freq);
   bse_engine_constrain (latency, mix_freq, BSE_GCONFIG (synth_control_freq), &block_size, NULL);
   /* try opening devices */
-  if (!error)
+  if (error == 0)
     error = server_open_pcm_device (self, mix_freq, latency, block_size);
   guint aligned_freq = bse_pcm_device_frequency_align (mix_freq);
   if (error != 0 && aligned_freq != mix_freq)
@@ -548,9 +548,9 @@ bse_server_open_devices (BseServer *self)
       Bse::Error new_error = server_open_pcm_device (self, mix_freq, latency, block_size);
       error = new_error != 0 ? error : Bse::Error::NONE;
     }
-  if (!error)
+  if (error == 0)
     error = server_open_midi_device (self);
-  if (!error)
+  if (error == 0)
     {
       BseTrans *trans = bse_trans_open ();
       engine_init (self, bse_pcm_device_get_mix_freq (self->pcm_device));
diff --git a/bse/bsewave.cc b/bse/bsewave.cc
index 11051eb..0d64b56 100644
--- a/bse/bsewave.cc
+++ b/bse/bsewave.cc
@@ -131,7 +131,7 @@ bse_wave_add_inlined_wave_chunk (BseWave      *self,
 {
   assert_return (BSE_IS_WAVE (self), Bse::Error::INTERNAL);
   Bse::Error error = gsl_data_handle_open (wchunk->dcache->dhandle);
-  if (!error)
+  if (error == 0)
     self->open_handles = sfi_ring_append (self->open_handles, wchunk->dcache->dhandle);
   return error;
 }
@@ -335,7 +335,7 @@ bse_wave_load_wave_file (BseWave      *self,
   else
     {
       error = gsl_file_check (file_name, "fr");
-      if (!error)
+      if (error == 0)
        error = Bse::Error::FILE_OPEN_FAILED;
     }
   return error;
@@ -656,7 +656,7 @@ bse_wave_restore_private (BseObject  *object,
          gsl_data_cache_unref (dcache);
           /* we need to keep inlined data handles open to protect against storage (.bse file) overwriting */
           Bse::Error error = bse_wave_add_inlined_wave_chunk (wave, wchunk);
-          if (!error)
+          if (error == 0)
             bse_wave_add_chunk (wave, wchunk);
           else
             {
@@ -701,7 +701,7 @@ bse_wave_get_index_for_modules (BseWave *wave)
       for (ring = wave->wave_chunks; ring; ring = sfi_ring_walk (ring, wave->wave_chunks))
        {
          Bse::Error error = gsl_wave_chunk_open ((GslWaveChunk*) ring->data);
-         if (!error)
+         if (error == 0)
             {
               index->entries[index->n_entries].wchunk = (GslWaveChunk*) ring->data;
               index->entries[index->n_entries].osc_freq = index->entries[index->n_entries].wchunk->osc_freq;
diff --git a/bse/bsewaverepo.proc b/bse/bsewaverepo.proc
index 7374dac..1713cf0 100644
--- a/bse/bsewaverepo.proc
+++ b/bse/bsewaverepo.proc
@@ -31,7 +31,7 @@ load_file (BseWaveRepo *wrepo,
     }
   else
     {
-      if (!error)
+      if (error == 0)
         error = Bse::Error::WAVE_NOT_FOUND;
       *wave_p = NULL;
     }
diff --git a/bse/gsldatahandle-mad.cc b/bse/gsldatahandle-mad.cc
index bee346b..169a61e 100644
--- a/bse/gsldatahandle-mad.cc
+++ b/bse/gsldatahandle-mad.cc
@@ -300,7 +300,7 @@ create_seek_table (MadHandle *handle,
        {
          g_free (seeks);
          /* frame read failed for a reason other than eof */
-          if (!handle->error)
+          if (handle->error == 0)
             handle->error = Bse::Error::IO;
          MDEBUG ("failed to read seektable frame: %s", handle->stream.error ? mad_stream_errorstr 
(&handle->stream) : bse_error_blurb (handle->error));
          return NULL;
@@ -677,7 +677,7 @@ dh_mad_new (const gchar  *file_name,
        */
       handle->skip_seek_table = skip_seek_keep_open != FALSE;
       Bse::Error error = gsl_data_handle_open (&handle->dhandle);
-      if (!error)
+      if (error == 0)
        {
          if (!skip_seek_keep_open)
            gsl_data_handle_close (&handle->dhandle);
diff --git a/bse/gsldatahandle-vorbis.cc b/bse/gsldatahandle-vorbis.cc
index 05a7a87..f2c5af7 100644
--- a/bse/gsldatahandle-vorbis.cc
+++ b/bse/gsldatahandle-vorbis.cc
@@ -403,7 +403,7 @@ gsl_data_handle_new_ogg_vorbis_any (const gchar *file_name,
        * to initialize things like the bitstream_serialno.
        */
       error = gsl_data_handle_open (&vhandle->dhandle);
-      if (!error)
+      if (error == 0)
        {
           if (n_channelsp)
             *n_channelsp = vhandle->dhandle.setup.n_channels;
diff --git a/bse/gsldatahandle.cc b/bse/gsldatahandle.cc
index d0b9ce1..06525ff 100644
--- a/bse/gsldatahandle.cc
+++ b/bse/gsldatahandle.cc
@@ -80,8 +80,7 @@ gsl_data_handle_open (GslDataHandle *dhandle)
     {
       GslDataHandleSetup setup = { 0, };
       Bse::Error error = dhandle->vtable->open (dhandle, &setup);
-      if (!error && (setup.n_values < 0 ||
-                    setup.n_channels < 1))
+      if (error == 0 && (setup.n_values < 0 || setup.n_channels < 1))
        {
          sfi_warning ("invalid parameters in data handle open() (%p()): nv=%lld nc=%u",
                        dhandle->vtable->open, setup.n_values, setup.n_channels);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]