diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2019-07-05 23:53:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-15 12:17:36 (GMT) |
commit | 90f91e4d217e64c5a68c8069500b83329eaee6b9 (patch) | |
tree | e68347c279b73d53ff89bab82aaf502d412904da /Source/cmProjectCommand.cxx | |
parent | 638383c38f58941692544401c44dfbce9c7ff2d9 (diff) | |
download | CMake-90f91e4d217e64c5a68c8069500b83329eaee6b9.zip CMake-90f91e4d217e64c5a68c8069500b83329eaee6b9.tar.gz CMake-90f91e4d217e64c5a68c8069500b83329eaee6b9.tar.bz2 |
Refactor: Replace a "magic" number w/ a named constant
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r-- | Source/cmProjectCommand.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a4ed300..c08ad0f 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -220,13 +220,14 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, return true; } + constexpr std::size_t MAX_VERSION_COMPONENTS = 4u; std::string vs; - char vb[4][64]; - unsigned int v[4] = { 0, 0, 0, 0 }; + char vb[MAX_VERSION_COMPONENTS][64]; + unsigned int v[MAX_VERSION_COMPONENTS] = { 0, 0, 0, 0 }; int vc = sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]); - for (int i = 0; i < 4; ++i) { - if (i < vc) { + for (auto i = 0u; i < MAX_VERSION_COMPONENTS; ++i) { + if (int(i) < vc) { sprintf(vb[i], "%u", v[i]); vs += &"."[size_t(i == 0)]; vs += vb[i]; |