[beast: 10/22] TOOLS: use Rapicorn's assert_return()



commit 0cfc62f82df0e4450b0f491cd97b82dd732f0aca
Author: Tim Janik <timj gnu org>
Date:   Mon Sep 21 19:47:49 2015 +0200

    TOOLS: use Rapicorn's assert_return()

 shell/bsescminterp.cc   |    8 +++---
 tests/bse/filtertest.cc |   10 ++++----
 tests/testresampler.cc  |    6 ++--
 tools/bsefcompare.cc    |   12 +++++-----
 tools/bsefextract.cc    |   10 ++++----
 tools/bseloopfuncs.cc   |   52 +++++++++++++++++++++++-----------------------
 tools/bsewavetool.cc    |    4 +-
 tools/bwtwave.cc        |    4 +-
 tools/sfiutils.cc       |   10 ++++----
 9 files changed, 58 insertions(+), 58 deletions(-)
---
diff --git a/shell/bsescminterp.cc b/shell/bsescminterp.cc
index 3ec5180..d2e1ad4 100644
--- a/shell/bsescminterp.cc
+++ b/shell/bsescminterp.cc
@@ -134,8 +134,8 @@ bse_scm_enter_gc (SCM           *scm_gc_list,
 {
   BseScmGCCell *gc_cell;
   SCM s_cell = 0;
-  g_return_if_fail (scm_gc_list != NULL);
-  g_return_if_fail (free_func != NULL);
+  assert_return (scm_gc_list != NULL);
+  assert_return (free_func != NULL);
   // g_printerr ("GCCell allocating %u bytes (%p).\n", size_hint, free_func);
   gc_cell = g_new (BseScmGCCell, 1);
   gc_cell->data = data;
@@ -222,7 +222,7 @@ bse_scm_from_glue_rec (SfiRec *rec)
 {
   SCM s_rec = 0;
 
-  g_return_val_if_fail (rec != NULL, SCM_UNSPECIFIED);
+  assert_return (rec != NULL, SCM_UNSPECIFIED);
 
   sfi_rec_ref (rec);
   SCM_NEWSMOB (s_rec, tc_glue_rec, rec);
@@ -673,7 +673,7 @@ signal_marshal_sproc (void *data)
   guint i;
 
   i = sdata->n_args;
-  g_return_val_if_fail (sdata->n_args > 0, SCM_UNSPECIFIED);
+  assert_return (sdata->n_args > 0, SCM_UNSPECIFIED);
   sdata->n_args = 0;
 
   while (i--)
diff --git a/tests/bse/filtertest.cc b/tests/bse/filtertest.cc
index fef921d..0c37b00 100644
--- a/tests/bse/filtertest.cc
+++ b/tests/bse/filtertest.cc
@@ -58,8 +58,8 @@ check_arg (uint         argc,
            const char  *opt,              /* for example: --foo */
            const char **opt_arg = NULL)   /* if foo needs an argument, pass a pointer to get the argument */
 {
-  g_return_val_if_fail (opt != NULL, false);
-  g_return_val_if_fail (*nth < argc, false);
+  assert_return (opt != NULL, false);
+  assert_return (*nth < argc, false);
 
   const char *arg = argv[*nth];
   if (!arg)
@@ -107,7 +107,7 @@ Options::parse (int   *argc_p,
   gchar **argv = *argv_p;
   unsigned int i;
 
-  g_return_if_fail (argc >= 0);
+  assert_return (argc >= 0);
 
   for (i = 1; i < argc; i++)
     {
@@ -233,8 +233,8 @@ private:
              guint       scan_points) const
   {
     const double delta_f = (FS / 2) / scan_points;
-    g_return_if_fail (band.freq_start <= band.freq_end);
-    g_return_if_fail (band.freq_end <= FS/2);
+    assert_return (band.freq_start <= band.freq_end);
+    assert_return (band.freq_end <= FS/2);
     TOUT ("checking band: response in interval [%f..%f] should be in interval [%f..%f] dB\n",
           band.freq_start, band.freq_end, band.min_resp_db, band.max_resp_db);
     int tok = 0;
diff --git a/tests/testresampler.cc b/tests/testresampler.cc
index 58e638c..58b74c4 100644
--- a/tests/testresampler.cc
+++ b/tests/testresampler.cc
@@ -134,8 +134,8 @@ check_arg (uint         argc,
            const char  *opt,              /* for example: --foo */
            const char **opt_arg = NULL)   /* if foo needs an argument, pass a pointer to get the argument */
 {
-  g_return_val_if_fail (opt != NULL, false);
-  g_return_val_if_fail (*nth < argc, false);
+  assert_return (opt != NULL, false);
+  assert_return (*nth < argc, false);
 
   const char *arg = argv[*nth];
   if (!arg)
@@ -183,7 +183,7 @@ Options::parse (int   *argc_p,
   gchar **argv = *argv_p;
   unsigned int i;
 
-  g_return_if_fail (argc >= 0);
+  assert_return (argc >= 0);
 
   /*  I am tired of seeing .libs/lt-bsefcompare all the time,
    *  but basically this should be done (to allow renaming the binary):
diff --git a/tools/bsefcompare.cc b/tools/bsefcompare.cc
index c3de4d5..95db6cf 100644
--- a/tools/bsefcompare.cc
+++ b/tools/bsefcompare.cc
@@ -46,8 +46,8 @@ check_arg (uint         argc,
            const char  *opt,              /* for example: --foo */
            const char **opt_arg = NULL)   /* if foo needs an argument, pass a pointer to get the argument */
 {
-  g_return_val_if_fail (opt != NULL, false);
-  g_return_val_if_fail (*nth < argc, false);
+  assert_return (opt != NULL, false);
+  assert_return (*nth < argc, false);
 
   const char *arg = argv[*nth];
   if (!arg)
@@ -95,7 +95,7 @@ Options::parse (int   *argc_p,
   gchar **argv = *argv_p;
   unsigned int i;
 
-  g_return_if_fail (argc >= 0);
+  assert_return (argc >= 0);
 
   /*  I am tired of seeing .libs/lt-bsefcompare all the time,
    *  but basically this should be done (to allow renaming the binary):
@@ -411,7 +411,7 @@ public:
   void
   register_strategy (const string& feature_name)
   {
-    g_return_if_fail (!m_strategies[feature_name]);
+    assert_return (!m_strategies[feature_name]);
 
     m_strategies[feature_name] = this;
   }
@@ -424,7 +424,7 @@ public:
     // produce a warning for a strategy with the right feature name but a wrong type
     if (s)
       {
-       g_return_val_if_fail (type == s->type(), 0);
+       assert_return (type == s->type(), 0);
       }
     return s;
   }
@@ -635,7 +635,7 @@ FeatureValueFile::parseFeatureValue (GScanner *scanner)
 void
 FeatureValueFile::parse (const string& filename)
 {
-  g_return_if_fail (this->filename == "");
+  assert_return (this->filename == "");
   this->filename = filename;
 
   GScanner *scanner = g_scanner_new64 (&scanner_config_template);
diff --git a/tools/bsefextract.cc b/tools/bsefextract.cc
index 6b4f859..ed8b495 100644
--- a/tools/bsefextract.cc
+++ b/tools/bsefextract.cc
@@ -378,13 +378,13 @@ struct SpectrumFeature : public Feature
                      double                                   normalize)
   {
     const vector < double > empty_return; // this can't be inlined in g_return* due to a bug in g++-3.3
-    g_return_val_if_fail (end - start > 0, empty_return);
+    assert_return (end - start > 0, empty_return);
 
     vector<double> result (start->size());
 
     for (vector< vector<double> >::const_iterator spect_it = start; spect_it != end; spect_it++)
       {
-       g_return_val_if_fail (spect_it->size() == result.size(), result);
+       assert_return (spect_it->size() == result.size(), result);
 
        for (size_t i = 0; i < result.size(); i++)
          result[i] += (*spect_it)[i];
@@ -1292,8 +1292,8 @@ check_arg (uint         argc,
            const char  *opt,             /* for example: --foo */
            const char **opt_arg = NULL)          /* if foo needs an argument, pass a pointer to get the 
argument */
 {
-  g_return_val_if_fail (opt != NULL, false);
-  g_return_val_if_fail (*nth < argc, false);
+  assert_return (opt != NULL, false);
+  assert_return (*nth < argc, false);
 
   const char *arg = argv[*nth];
   if (!arg)
@@ -1341,7 +1341,7 @@ Options::parse (int   *argc_p,
   gchar **argv = *argv_p;
   unsigned int i, e;
 
-  g_return_if_fail (argc >= 0);
+  assert_return (argc >= 0);
 
   /*  I am tired of seeing .libs/lt-bsefextract all the time,
    *  but basically this should be done (to allow renaming the binary):
diff --git a/tools/bseloopfuncs.cc b/tools/bseloopfuncs.cc
index 2794d01..bd198d0 100644
--- a/tools/bseloopfuncs.cc
+++ b/tools/bseloopfuncs.cc
@@ -119,9 +119,9 @@ gsl_data_find_loop5 (GslDataHandle     *dhandle,
   gfloat *block;
   gboolean found_loop = FALSE;
 
-  g_return_val_if_fail (dhandle != NULL, FALSE);
-  g_return_val_if_fail (config != NULL, FALSE);
-  g_return_val_if_fail (frame <= config->block_start, FALSE);
+  assert_return (dhandle != NULL, FALSE);
+  assert_return (config != NULL, FALSE);
+  assert_return (frame <= config->block_start, FALSE);
   config->n_details = 0;
 
   /* check out data handle */
@@ -267,8 +267,8 @@ gsl_data_find_loop4 (GslDataHandle     *dhandle,
   const gfloat *block;
   gboolean found_loop = FALSE;
 
-  g_return_val_if_fail (dhandle != NULL, FALSE);
-  g_return_val_if_fail (config != NULL, FALSE);
+  assert_return (dhandle != NULL, FALSE);
+  assert_return (config != NULL, FALSE);
   config->n_details = 0;
 
   /* check out data handle */
@@ -383,8 +383,8 @@ gsl_data_find_loop3 (GslDataHandle     *dhandle,
   gdouble pdist;
   gboolean found_loop = FALSE;
 
-  g_return_val_if_fail (dhandle != NULL, FALSE);
-  g_return_val_if_fail (config != NULL, FALSE);
+  assert_return (dhandle != NULL, FALSE);
+  assert_return (config != NULL, FALSE);
   config->n_details = 0;
 
   if (gsl_data_handle_open (dhandle) != Bse::ERROR_NONE)
@@ -400,7 +400,7 @@ gsl_data_find_loop3 (GslDataHandle     *dhandle,
   if (config->repetitions != CLAMP (config->repetitions, 2, config->block_length))
     return FALSE;
   /* current implementation supports just repetitions == 2 */
-  g_return_val_if_fail (config->repetitions == 2, FALSE);
+  assert_return (config->repetitions == 2, FALSE);
 
   /* provide fully cached area for comparisons */
   block = g_new (gfloat, config->block_length);
@@ -410,7 +410,7 @@ gsl_data_find_loop3 (GslDataHandle     *dhandle,
   /* test every possible loop size at every possible position */
   maxll = config->block_length / 2;
   minll = maxll * 0.91;
-  g_return_val_if_fail (maxll > minll, FALSE); // FIXME
+  assert_return (maxll > minll, FALSE); // FIXME
   cstart = block + config->block_length / 2;
   config->score = G_MAXDOUBLE;
   pcount = 0, pdist = (maxll * 1.0 - minll * 1.0 + 2.0) * (maxll * 1.0 - minll * 1.0 + 1.0) / 2.;
@@ -448,8 +448,8 @@ gsl_data_find_loop2 (GslDataHandle     *dhandle,
   gdouble pdist;
   gboolean found_loop = FALSE;
 
-  g_return_val_if_fail (dhandle != NULL, FALSE);
-  g_return_val_if_fail (config != NULL, FALSE);
+  assert_return (dhandle != NULL, FALSE);
+  assert_return (config != NULL, FALSE);
   config->n_details = 0;
 
   if (gsl_data_handle_open (dhandle) != Bse::ERROR_NONE)
@@ -465,7 +465,7 @@ gsl_data_find_loop2 (GslDataHandle     *dhandle,
   if (config->repetitions != CLAMP (config->repetitions, 2, config->block_length))
     return FALSE;
   /* current implementation supports just repetitions == 2 */
-  g_return_val_if_fail (config->repetitions == 2, FALSE);
+  assert_return (config->repetitions == 2, FALSE);
 
   /* provide fully cached area for comparisons */
   block = g_new (gfloat, config->block_length);
@@ -477,7 +477,7 @@ gsl_data_find_loop2 (GslDataHandle     *dhandle,
   /* find best loop size at one position */
   maxll = config->block_length / 2;
   minll = 1;
-  g_return_val_if_fail (maxll > minll, FALSE); // FIXME
+  assert_return (maxll > minll, FALSE); // FIXME
   cstart = block + config->block_length / 2;
   config->score = G_MAXDOUBLE;
   pcount = 0, pdist = (maxll * 1.0 - minll * 1.0 + 2.0) * (maxll * 1.0 - minll * 1.0 + 1.0) / 2.;
@@ -501,7 +501,7 @@ gsl_data_find_loop2 (GslDataHandle     *dhandle,
   /* test every possible position */
   minll = ll;
   maxll = ll + 1;
-  g_return_val_if_fail (maxll > minll, FALSE); // FIXME
+  assert_return (maxll > minll, FALSE); // FIXME
   cstart = block + config->block_length / 2;
   config->score = G_MAXDOUBLE;
   pcount = 0, pdist = (maxll * 1.0 - minll * 1.0 + 2.0) * (maxll * 1.0 - minll * 1.0 + 1.0) / 2.;
@@ -530,7 +530,7 @@ gsl_data_find_loop2 (GslDataHandle     *dhandle,
   /* test every possible loop size */
   maxll = config->block_length / 2;
   minll = 1;
-  g_return_val_if_fail (maxll > minll, FALSE); // FIXME
+  assert_return (maxll > minll, FALSE); // FIXME
   cstart = block + config->block_length / 2;
   config->score = G_MAXDOUBLE;
   pcount = 0, pdist = (maxll * 1.0 - minll * 1.0 + 2.0) * (maxll * 1.0 - minll * 1.0 + 1.0) / 2.;
@@ -632,8 +632,8 @@ gsl_data_find_loop1 (GslDataHandle    *dhandle,
   gdouble pdist;
   gboolean found_loop = FALSE;
 
-  g_return_val_if_fail (dhandle != NULL, FALSE);
-  g_return_val_if_fail (config != NULL, FALSE);
+  assert_return (dhandle != NULL, FALSE);
+  assert_return (config != NULL, FALSE);
   config->n_details = 0;
 
   if (gsl_data_handle_open (dhandle) != Bse::ERROR_NONE)
@@ -852,21 +852,21 @@ gsl_data_find_loop0 (GslDataHandle         *dhandle,
   GslLong loopsize, bestloopsize = 0;
   gdouble bestscore;
 
-  g_return_val_if_fail (dhandle != NULL, 0);
-  g_return_val_if_fail (cfg != NULL, 0);
-  g_return_val_if_fail (loop_start_p != NULL, 0);
-  g_return_val_if_fail (loop_end_p != NULL, 0);
-  g_return_val_if_fail (cfg->min_loop >= 1, 0);
+  assert_return (dhandle != NULL, 0);
+  assert_return (cfg != NULL, 0);
+  assert_return (loop_start_p != NULL, 0);
+  assert_return (loop_end_p != NULL, 0);
+  assert_return (cfg->min_loop >= 1, 0);
 
   if (gsl_data_handle_open (dhandle) != Bse::ERROR_NONE)
     return 0;
   dhandle_n_values = gsl_data_handle_n_values (dhandle);
 
-  g_return_val_if_fail (cfg->pre_loop_compare < dhandle_n_values - 1, 0);
+  assert_return (cfg->pre_loop_compare < dhandle_n_values - 1, 0);
   cfg_max_loop = cfg->max_loop < 0 ? dhandle_n_values - 1 - cfg->pre_loop_compare : cfg->max_loop;
-  g_return_val_if_fail (cfg_max_loop >= cfg->min_loop, 0);
-  g_return_val_if_fail (cfg->pre_loop_compare + cfg_max_loop < dhandle_n_values, 0);
-  g_return_val_if_fail (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE ||
+  assert_return (cfg_max_loop >= cfg->min_loop, 0);
+  assert_return (cfg->pre_loop_compare + cfg_max_loop < dhandle_n_values, 0);
+  assert_return (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE ||
                        cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION, 0);
 
   dcache = gsl_data_cache_new (dhandle, 1);
diff --git a/tools/bsewavetool.cc b/tools/bsewavetool.cc
index da20aac..564bfa2 100644
--- a/tools/bsewavetool.cc
+++ b/tools/bsewavetool.cc
@@ -1546,7 +1546,7 @@ public:
     int64 n_channels = gsl_data_handle_n_channels (dhandle);
     int64 n_frames = n_values / n_channels;
 
-    g_return_val_if_fail (n_values % n_channels == 0, n_frames);  /* a datahandle cannot contain half frames 
*/
+    assert_return (n_values % n_channels == 0, n_frames);  /* a datahandle cannot contain half frames */
     return n_frames;
   }
   static double
@@ -1554,7 +1554,7 @@ public:
                       double         volume_adjustment)
   {
     const double min_db = -200;
-    g_return_val_if_fail (GSL_DATA_HANDLE_OPENED (dhandle), min_db);
+    assert_return (GSL_DATA_HANDLE_OPENED (dhandle), min_db);
 
     /* We do not take into account that a data handle can contain many separate
      * channels, so we're effectively averaging over all channels here.
diff --git a/tools/bwtwave.cc b/tools/bwtwave.cc
index d4ea403..129e0c1 100644
--- a/tools/bwtwave.cc
+++ b/tools/bwtwave.cc
@@ -111,7 +111,7 @@ Bse::ErrorType
 Wave::add_chunk (GslDataHandle  *dhandle,
                  gchar         **xinfos)
 {
-  g_return_val_if_fail (dhandle != NULL, Bse::ERROR_INTERNAL);
+  assert_return (dhandle != NULL, Bse::ERROR_INTERNAL);
 
   if (xinfos)
     {
@@ -236,7 +236,7 @@ Wave::sort ()
 Bse::ErrorType
 Wave::store (const string file_name)
 {
-  g_return_val_if_fail (file_name.c_str() != NULL, Bse::ERROR_INTERNAL);
+  assert_return (file_name.c_str() != NULL, Bse::ERROR_INTERNAL);
 
   /* save to temporary file */
   gint fd;
diff --git a/tools/sfiutils.cc b/tools/sfiutils.cc
index f1ecf88..33a16c7 100644
--- a/tools/sfiutils.cc
+++ b/tools/sfiutils.cc
@@ -26,7 +26,7 @@ parse_arguments (gint              *argc_p,
 
   for (i = 0; i < n_arguments; i++)
     {
-      g_return_val_if_fail (arguments[i].value_p != NULL, NULL);
+      assert_return (arguments[i].value_p != NULL, NULL);
 
       lengths[i] = arguments[i].long_opt ? strlen (arguments[i].long_opt) : 0;
     }
@@ -212,8 +212,8 @@ sfi_util_file_name_subst_ext (const gchar *file_name,
 {
   gchar *p, *name;
 
-  g_return_val_if_fail (file_name != NULL, NULL);
-  g_return_val_if_fail (new_extension != NULL, NULL);
+  assert_return (file_name != NULL, NULL);
+  assert_return (new_extension != NULL, NULL);
 
   name = g_strdup (file_name);
   p = strrchr (name, '.');
@@ -339,8 +339,8 @@ sfi_util_file_list_read_simple (const gchar *file_name,
   guint i;
   gint fd;
 
-  g_return_val_if_fail (file_name != NULL, NULL);
-  g_return_val_if_fail (n_formats < 1000, NULL);
+  assert_return (file_name != NULL, NULL);
+  assert_return (n_formats < 1000, NULL);
 
   fd = open (file_name, O_RDONLY);
   if (fd < 0)


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