[beast: 41/57] SFI: rename fatal_error() and add a disclaimer to avoid it in libraries



commit d48335c85e5de621bac2a377a7c5776163584fa6
Author: Tim Janik <timj gnu org>
Date:   Mon Jul 17 12:12:25 2017 +0200

    SFI: rename fatal_error() and add a disclaimer to avoid it in libraries
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bseenginemaster.cc |    4 ++--
 bse/bsemain.cc         |    2 +-
 bse/bsesequencer.cc    |    2 +-
 bse/bsestorage.cc      |    4 +++-
 sfi/bcore.hh           |    9 ++++++---
 tests/testwavechunk.cc |    6 +++---
 6 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index e8e5fd6..1b22d4f 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -1200,7 +1200,7 @@ MasterThread::MasterThread (const std::function<void()> &caller_wakeup) :
 {
   assert_return (caller_wakeup_ != NULL);
   if (event_fd_.open() != 0)
-    fatal ("BSE: failed to create master thread wake-up pipe: %s", strerror (errno));
+    warning ("BSE: failed to create master thread wake-up pipe: %s", strerror (errno));
 }
 
 static std::atomic<bool> master_thread_running { false };
@@ -1278,7 +1278,7 @@ MasterThread::start (const std::function<void()> &caller_wakeup)
   master_thread_singleton = mthread;
   assert_return (master_thread_running == false);
   if (std::atexit (reap_master_thread) != 0)
-    fatal ("BSE: failed to install master thread reaper");
+    warning ("BSE: failed to install master thread reaper");
   master_thread_running = true;
   mthread->thread_ = std::thread (&MasterThread::master_thread, mthread);
   BseInternal::engine_start_slaves();
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index d454652..b9a8d90 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -254,7 +254,7 @@ _bse_init_async (int *argc, char **argv, const char *app_name, const Bse::String
 
   // start main BSE thread
   if (std::atexit (reap_main_loop_thread) != 0)
-    Bse::fatal ("BSE: failed to install main thread reaper");
+    Bse::warning ("BSE: failed to install main thread reaper");
   auto *init_queue = new Rapicorn::AsyncBlockingQueue<int>();
   async_bse_thread = std::thread (bse_main_loop_thread, init_queue); // calls bse_init_intern
   // wait for initialization completion of the core thread
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index 6152f26..36f36e8 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -566,7 +566,7 @@ Sequencer::_init_threaded ()
   assert_return (sequencer_thread_running == false);
   singleton_ = new Sequencer();
   if (std::atexit (Sequencer::reap_thread) != 0)
-    fatal ("BSE: failed to install sequencer thread reaper");
+    warning ("BSE: failed to install sequencer thread reaper");
   sequencer_thread_running = true;
   singleton_->thread_ = std::thread (&Sequencer::sequencer_thread, singleton_); // FIXME: join on exit
 }
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index 3e6da1b..dd5c900 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -660,7 +660,9 @@ any_set_from_string (BseStorage *self, Bse::Any &any, const std::string &string)
           any.set_enum (einfo, v);
         break;
       }
-    default:                    Bse::fatal ("unhandled Any: %s; string=%s", any.repr(), string);
+    default:
+      Bse::warn ("unhandled Any: %s; string=%s", any.repr(), string);
+      return false;
     }
   return true;
 }
diff --git a/sfi/bcore.hh b/sfi/bcore.hh
index b290b5f..bfe557e 100644
--- a/sfi/bcore.hh
+++ b/sfi/bcore.hh
@@ -35,7 +35,7 @@ template<class... Args> String      string_format        (const char *format, co
 template<class... Args> String      string_locale_format (const char *format, const Args &...args) 
BSE_PRINTF (1, 0);
 template<class... Args> void        printout             (const char *format, const Args &...args) 
BSE_PRINTF (1, 0);
 template<class... Args> void        printerr             (const char *format, const Args &...args) 
BSE_PRINTF (1, 0);
-template<class ...Args> void        fatal                (const char *format, const Args &...args) 
BSE_NORETURN;
+template<class ...Args> void        fatal_error          (const char *format, const Args &...args) 
BSE_NORETURN;
 template<class ...Args> void        warning              (const char *format, const Args &...args);
 template<class ...Args> void        warn                 (const char *format, const Args &...args);
 template<class ...Args> void        info                 (const char *format, const Args &...args);
@@ -186,9 +186,12 @@ debug_enabled (const char *conditional)
   return false;
 }
 
-/// Issue a printf-like message and abort the program, this function will not return.
+/** Issue a printf-like message and abort the program, this function will not return.
+ * Avoid using this in library code, aborting may take precious user data with it,
+ * library code should instead use info() or assert_return().
+ */
 template<class ...Args> void BSE_NORETURN
-fatal (const char *format, const Args &...args)
+fatal_error (const char *format, const Args &...args)
 {
   Internal::diagnostic ('F', string_format (format, args...));
   Internal::force_abort();
diff --git a/tests/testwavechunk.cc b/tests/testwavechunk.cc
index 29ec9cb..4aaff2d 100644
--- a/tests/testwavechunk.cc
+++ b/tests/testwavechunk.cc
@@ -95,9 +95,9 @@ run_loop_test (GslWaveLoopType loop_type,
        }
       if (abort)
        {
-          Bse::fatal ("mismatches occoured, setup: loop_type=%u loop_first=%lld loop_last=%lld loop_count=%d 
(length=%lld)",
-                      wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count,
-                      gsl_data_handle_length (wchunk->dcache->dhandle));
+          Bse::fatal_error ("mismatches occoured, setup: loop_type=%u loop_first=%lld loop_last=%lld 
loop_count=%d (length=%lld)",
+                            wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count,
+                            gsl_data_handle_length (wchunk->dcache->dhandle));
        }
       gsl_wave_chunk_unuse_block (wchunk, &block);
       block.offset = block.next_offset;


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