From db73d59969185bc3c261b39e3a6e9e2462b14a3a Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 10 Nov 2017 17:01:24 -0800 Subject: uhd: Remove keys from device hashing --- host/lib/device.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'host/lib') diff --git a/host/lib/device.cpp b/host/lib/device.cpp index ca76781da..d0aa0f200 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -36,14 +36,27 @@ static size_t hash_device_addr( //combine the hashes of sorted keys/value pairs size_t hash = 0; + // The device addr can contain all sorts of stuff, which sometimes gets in + // the way of hashing reliably. TODO: Make this a whitelist + const std::vector hash_key_blacklist = { + "claimed", + "skip_dram", + "skip_ddc", + "skip_duc" + }; + if(dev_addr.has_key("resource")) { boost::hash_combine(hash, "resource"); boost::hash_combine(hash, dev_addr["resource"]); } else { - for(const std::string &key: uhd::sorted(dev_addr.keys())){ - boost::hash_combine(hash, key); - boost::hash_combine(hash, dev_addr[key]); + for (const std::string &key: uhd::sorted(dev_addr.keys())) { + if (std::find(hash_key_blacklist.begin(), + hash_key_blacklist.end(), + key) == hash_key_blacklist.end()) { + boost::hash_combine(hash, key); + boost::hash_combine(hash, dev_addr[key]); + } } } return hash; -- cgit v1.2.3