diff options
author | Michael West <michael.west@ettus.com> | 2018-05-29 16:41:32 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-05-31 01:50:23 +0200 |
commit | d19c7590331b7b666e29e7bb2e8f588bef818966 (patch) | |
tree | c73c8ce053253b511a9935bb6a1b8f470eb014a8 /host/lib/usrp/x300/x300_impl.cpp | |
parent | 208c2c9639ca7cf09a9f716bb3865cd61a8d257d (diff) | |
download | uhd-d19c7590331b7b666e29e7bb2e8f588bef818966.tar.gz uhd-d19c7590331b7b666e29e7bb2e8f588bef818966.tar.bz2 uhd-d19c7590331b7b666e29e7bb2e8f588bef818966.zip |
x300_impl: Assign Channel Variable Before Err Check
Diffstat (limited to 'host/lib/usrp/x300/x300_impl.cpp')
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 5f5aae403..2627ff1a2 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -1126,15 +1126,16 @@ uint32_t x300_impl::mboard_members_t::allocate_pcie_dma_chan(const uhd::sid_t &t uint32_t raw_sid = tx_sid.get(); if (_dma_chan_pool.count(raw_sid) == 0) { - _dma_chan_pool[raw_sid] = _dma_chan_pool.size() + FIRST_DATA_CHANNEL; + size_t channel = _dma_chan_pool.size() + FIRST_DATA_CHANNEL; + if (channel > X300_PCIE_MAX_CHANNELS) { + throw uhd::runtime_error("Trying to allocate more DMA channels than are available"); + } + _dma_chan_pool[raw_sid] = channel; UHD_LOGGER_DEBUG("X300") << "Assigning PCIe DMA channel " << _dma_chan_pool[raw_sid] << " to SID " << tx_sid.to_pp_string_hex(); } - if (_dma_chan_pool.size() + FIRST_DATA_CHANNEL > X300_PCIE_MAX_CHANNELS) { - throw uhd::runtime_error("Trying to allocate more DMA channels than are available"); - } return _dma_chan_pool[raw_sid]; } } |