From b185c9447a4a33bff14fd697dc294b9ee5d298b3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 10 Jul 2018 22:24:49 -0700 Subject: soft_register: Remove compiler warning, add unit test --- host/include/uhd/utils/soft_register.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/utils/soft_register.hpp b/host/include/uhd/utils/soft_register.hpp index ac6ad4b35..fea4c0791 100644 --- a/host/include/uhd/utils/soft_register.hpp +++ b/host/include/uhd/utils/soft_register.hpp @@ -85,14 +85,16 @@ namespace soft_reg_field { template UHD_INLINE data_t mask(const soft_reg_field_t field) { - static const data_t ONE = static_cast(1); + constexpr data_t ONE = static_cast(1); + constexpr data_t ALL_ONES = ~static_cast(0); //Behavior for the left shift operation is undefined in C++ //if the shift amount is >= bitwidth of the datatype //So we treat that as a special case with a branch predicition hint - if (likely((sizeof(data_t)*8) != width(field))) + if (likely((sizeof(data_t)*8) != width(field))) { return ((ONE<