From 08ea2451013052fbeeb9ed2ccf894cc56668dfd8 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Wed, 27 Jul 2016 10:04:56 -0700 Subject: [PATCH] Hoist version string to namespace level --- src/ripple/protocol/BuildInfo.h | 3 -- src/ripple/protocol/impl/BuildInfo.cpp | 29 +++++++------------- src/ripple/protocol/tests/BuildInfo.test.cpp | 11 -------- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/ripple/protocol/BuildInfo.h b/src/ripple/protocol/BuildInfo.h index 916826e07f..5fdc8aa177 100644 --- a/src/ripple/protocol/BuildInfo.h +++ b/src/ripple/protocol/BuildInfo.h @@ -57,9 +57,6 @@ getCurrentProtocol(); /** The oldest protocol version we will accept. */ ProtocolVersion const& getMinimumProtocol (); -char const* -getRawVersionString(); - } // BuildInfo (DEPRECATED) std::string diff --git a/src/ripple/protocol/impl/BuildInfo.cpp b/src/ripple/protocol/impl/BuildInfo.cpp index 0356732788..30d3ce467a 100644 --- a/src/ripple/protocol/impl/BuildInfo.cpp +++ b/src/ripple/protocol/impl/BuildInfo.cpp @@ -27,22 +27,15 @@ namespace ripple { namespace BuildInfo { -char const* getRawVersionString () -{ - static char const* const rawText = +//------------------------------------------------------------------------------ +char const* const versionString = //-------------------------------------------------------------------------- - // - // The build version number (edit this for each release) + // The build version number. You must edit this for each release + // and follow the format described here at http://semver.org/ // "0.32.1" - // - // Must follow the format described here: - // - // http://semver.org/ - // - #if defined(DEBUG) || defined(SANITIZER) "+" #ifdef DEBUG @@ -60,9 +53,6 @@ char const* getRawVersionString () //-------------------------------------------------------------------------- ; - return rawText; -} - ProtocolVersion const& getCurrentProtocol () { @@ -108,18 +98,19 @@ std::string const& getVersionString () { static std::string const value = [] { - std::string const versionString = getRawVersionString (); + std::string const s = versionString; beast::SemanticVersion v; - if (!v.parse (versionString) || v.print () != versionString) - LogicError (versionString + ": Bad server version string"); - return versionString; + if (!v.parse (s) || v.print () != s) + LogicError (s + ": Bad server version string"); + return s; }(); return value; } std::string const& getFullVersionString () { - static std::string const value = "rippled-" + getVersionString (); + static std::string const value = + "rippled-" + getVersionString(); return value; } diff --git a/src/ripple/protocol/tests/BuildInfo.test.cpp b/src/ripple/protocol/tests/BuildInfo.test.cpp index a8a148d667..c0817b90d7 100644 --- a/src/ripple/protocol/tests/BuildInfo.test.cpp +++ b/src/ripple/protocol/tests/BuildInfo.test.cpp @@ -27,16 +27,6 @@ namespace ripple { class BuildInfo_test : public beast::unit_test::suite { public: - void testVersion () - { - testcase ("version"); - - beast::SemanticVersion v; - - BEAST_EXPECT(v.parse (BuildInfo::getRawVersionString ())); - } - - ProtocolVersion from_version (std::uint16_t major, std::uint16_t minor) { @@ -97,7 +87,6 @@ public: void run () { - testVersion (); testValues (); testStringVersion (); testVersionPacking ();