From 5920b2bac341507121dda41e905a663edf835772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Thu, 2 Apr 2015 17:03:13 -0400 Subject: [PATCH] infohash: make string constructor explicit --- include/opendht/infohash.h | 2 +- tools/dhtchat.cpp | 2 +- tools/dhtnode.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h index fb0480e7..e171d440 100644 --- a/include/opendht/infohash.h +++ b/include/opendht/infohash.h @@ -71,7 +71,7 @@ public: * hex must be at least 2.HASH_LEN characters long. * If too long, only the first 2.HASH_LEN characters are read. */ - InfoHash(const std::string& hex); + explicit InfoHash(const std::string& hex); /** * Find the lowest 1 bit in an id. diff --git a/tools/dhtchat.cpp b/tools/dhtchat.cpp index b296bf8d..91351934 100644 --- a/tools/dhtchat.cpp +++ b/tools/dhtchat.cpp @@ -132,7 +132,7 @@ main(int argc, char **argv) if (op == "x" || op == "q" || op == "exit" || op == "quit") break; else if (op == "c") { - room = idstr; + room = InfoHash(idstr); if (room == INVALID_ID) { std::cout << "Syntax error: invalid InfoHash." << std::endl; continue; diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index 7dfd4e1a..fea36c3d 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -242,7 +242,7 @@ main(int argc, char **argv) std::string tostr; std::string v; iss >> tostr >> v; - dht.putEncrypted(id, tostr, dht::Value { + dht.putEncrypted(id, InfoHash(tostr), dht::Value { dht::ValueType::USER_DATA.id, std::vector {v.begin(), v.end()} }, [](bool ok) {