aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Crymble <matthew.crymble@ni.com>2020-06-25 20:02:24 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-06-26 14:31:14 -0500
commit9318323b769200ee328456b0ef92ea19c1b96b6e (patch)
tree1b5b0df89eafa0e1b6e6ff453ffb730f8410ec8a
parent27232433a2ed8aa60a59a417a47703627ad8581c (diff)
downloaduhd-9318323b769200ee328456b0ef92ea19c1b96b6e.tar.gz
uhd-9318323b769200ee328456b0ef92ea19c1b96b6e.tar.bz2
uhd-9318323b769200ee328456b0ef92ea19c1b96b6e.zip
uhd: improved handling of empty serial number hints
This allows device::find() calls to proceed even when encountering an empty/invalid serial number or serial number device argument hint.
-rw-r--r--host/lib/utils/serial_number.cpp2
-rw-r--r--host/tests/serial_number_test.cpp3
2 files changed, 5 insertions, 0 deletions
diff --git a/host/lib/utils/serial_number.cpp b/host/lib/utils/serial_number.cpp
index af66197fd..61296a913 100644
--- a/host/lib/utils/serial_number.cpp
+++ b/host/lib/utils/serial_number.cpp
@@ -17,6 +17,8 @@ namespace uhd { namespace utils {
return a == b;
} catch (std::out_of_range& e) {
return false;
+ } catch (std::invalid_argument& e) {
+ return false;
}
}
}}
diff --git a/host/tests/serial_number_test.cpp b/host/tests/serial_number_test.cpp
index f2dc4bb42..e873bc538 100644
--- a/host/tests/serial_number_test.cpp
+++ b/host/tests/serial_number_test.cpp
@@ -19,4 +19,7 @@ BOOST_AUTO_TEST_CASE(test_serial_numbers_match)
// Out of range
BOOST_CHECK_EQUAL(false, uhd::utils::serial_numbers_match("aaaaaaaaaaaaaa", "abcd123"));
+
+ // Invalid argument
+ BOOST_CHECK_EQUAL(false, uhd::utils::serial_numbers_match("", "abcd123"));
}