commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/02: blocks: fix incorrect use of items/b


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/02: blocks: fix incorrect use of items/bytes in PDU handling
Date: Mon, 8 Feb 2016 16:47:30 +0000 (UTC)

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

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 0f9bab7c0e46e029cbe1864cfd766dc7a80897ef
Author: Jacob Gilbert <address@hidden>
Date:   Mon Feb 8 07:36:01 2016 -0800

    blocks: fix incorrect use of items/bytes in PDU handling
    
    For a uniform vector, calls to pmt::length return the number
    of items in in the vector.  However, in some places this was
    being treated as a byte value, resulting in short writes and
    other misinterpretations.
    
    These calls have been replaced with calls to pmt::blob_length,
    to unambiguously get the length in bytes, then converted if
    necessary to item values.
---
 gr-blocks/lib/message_debug_impl.cc        | 2 +-
 gr-blocks/lib/pdu_to_tagged_stream_impl.cc | 3 ++-
 gr-blocks/lib/socket_pdu_impl.cc           | 4 ++--
 gr-blocks/lib/tcp_connection.cc            | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gr-blocks/lib/message_debug_impl.cc 
b/gr-blocks/lib/message_debug_impl.cc
index 620ca1e..8bab788 100644
--- a/gr-blocks/lib/message_debug_impl.cc
+++ b/gr-blocks/lib/message_debug_impl.cc
@@ -61,7 +61,7 @@ namespace gr {
       pmt::pmt_t vector = pmt::cdr(pdu);
       std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
       pmt::print(meta);
-      size_t len = pmt::length(vector);
+      size_t len = pmt::blob_length(vector);
       std::cout << "pdu_length = " << len << std::endl;
       std::cout << "contents = " << std::endl;
       size_t offset(0);
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc 
b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
index 3a2b50e..aec5d33 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
@@ -65,7 +65,8 @@ namespace gr {
 
         d_curr_meta = pmt::car(msg);
         d_curr_vect = pmt::cdr(msg);
-        d_curr_len = pmt::length(d_curr_vect);
+        // do not assume the length of  PMT is in items (e.g.: from socket_pdu)
+        d_curr_len = pmt::blob_length(d_curr_vect)/d_itemsize;
       }
 
       return d_curr_len;
diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
index 7f7abd5..cc45557 100644
--- a/gr-blocks/lib/socket_pdu_impl.cc
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -196,7 +196,7 @@ namespace gr {
     socket_pdu_impl::tcp_client_send(pmt::pmt_t msg)
     {
       pmt::pmt_t vector = pmt::cdr(msg);
-      size_t len = pmt::length(vector);
+      size_t len = pmt::blob_length(vector);
       size_t offset = 0;
       std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
       while (offset < len) {
@@ -214,7 +214,7 @@ namespace gr {
         return;
 
       pmt::pmt_t vector = pmt::cdr(msg);
-      size_t len = pmt::length(vector);
+      size_t len = pmt::blob_length(vector);
       size_t offset = 0;
       std::vector<char> txbuf(std::min(len, d_rxbuf.size()));
       while (offset < len) {
diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc
index 27bdf6a..3b0afa1 100644
--- a/gr-blocks/lib/tcp_connection.cc
+++ b/gr-blocks/lib/tcp_connection.cc
@@ -53,7 +53,7 @@ namespace gr {
     void
     tcp_connection::send(pmt::pmt_t vector)
     {
-      size_t len = pmt::length(vector);
+      size_t len = pmt::blob_length(vector);
       size_t offset = 0;
       std::vector<char> txbuf(std::min(len, d_buf.size()));
       while (offset < len) {



reply via email to

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