commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/03: blocks: convert asserts to throwing


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/03: blocks: convert asserts to throwing runtime errors in keep_m_in_n ctor.
Date: Thu, 25 Sep 2014 16:19:51 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 33f0601d27ad6ca1e9dc55ecce259f7eb9231385
Author: Tom Rondeau <address@hidden>
Date:   Thu Sep 25 10:02:47 2014 -0400

    blocks: convert asserts to throwing runtime errors in keep_m_in_n ctor.
---
 gr-blocks/lib/keep_m_in_n_impl.cc | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/gr-blocks/lib/keep_m_in_n_impl.cc 
b/gr-blocks/lib/keep_m_in_n_impl.cc
index e987b52..878531d 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.cc
+++ b/gr-blocks/lib/keep_m_in_n_impl.cc
@@ -30,25 +30,40 @@
 namespace gr {
   namespace blocks {
 
-    keep_m_in_n::sptr keep_m_in_n::make(size_t itemsize, int m, int n, int 
offset)
+    keep_m_in_n::sptr
+    keep_m_in_n::make(size_t itemsize, int m, int n, int offset)
     {
-      return gnuradio::get_initial_sptr(new keep_m_in_n_impl(itemsize, m, n, 
offset));
+      return gnuradio::get_initial_sptr
+        (new keep_m_in_n_impl(itemsize, m, n, offset));
     }
 
     keep_m_in_n_impl::keep_m_in_n_impl(size_t itemsize, int m, int n, int 
offset)
       : block("keep_m_in_n",
-                io_signature::make (1, 1, itemsize),
-                io_signature::make (1, 1, itemsize)),
+              io_signature::make (1, 1, itemsize),
+              io_signature::make (1, 1, itemsize)),
        d_m(m),
        d_n(n),
        d_offset(offset),
        d_itemsize(itemsize)
     {
       // sanity checking
-      assert(d_m > 0);
-      assert(d_n > 0);
-      assert(d_m <= d_n);
-      assert(d_offset <= (d_n-d_m));
+      if(d_m <= 0) {
+        std::string s = boost::str(boost::format("keep_m_in_n: m=%1% but must 
be > 0") % d_m);
+        throw std::runtime_error(s);
+      }
+      if(d_n <= 0) {
+        std::string s = boost::str(boost::format("keep_m_in_n: n=%1% but must 
be > 0") % d_n);
+        throw std::runtime_error(s);
+      }
+      if(d_m > d_n) {
+        std::string s = boost::str(boost::format("keep_m_in_n: m (%1%) <= n 
%2%") % d_m % d_n);
+        throw std::runtime_error(s);
+      }
+      if(d_offset < (d_n - d_m)) {
+        std::string s = boost::str(boost::format("keep_m_in_n: offset (%1%) <= 
n (%2%) - m (%3%)") \
+                                   % d_offset % d_n % d_m);
+        throw std::runtime_error(s);
+      }
 
       set_output_multiple(m);
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]