xaizek / uncov (License: AGPLv3+) (since 2018-12-07)
Uncov(er) is a tool that collects and processes code coverage reports.
Commit b63061568df554e3bcffa6571e59971783dfe6f2

Fix UB due to wrong order of static initialization
GcovImporter::setRunner() could be called before GcovImporter::runner
was created.
Author: xaizek
Author date (UTC): 2020-02-21 23:55
Committer name: xaizek
Committer date (UTC): 2020-02-21 23:55
Parent(s): b81aedd9f4ce21be08b443ab64c7f9d32f3aaa39
Signing key: 99DC5E4DB05F6BE2
Tree: d66fe4af9157cdf057197dbd683dc7b98a57fc53
File Lines added Lines deleted
src/GcovImporter.cpp 9 4
src/GcovImporter.hpp 6 2
File src/GcovImporter.cpp changed (mode: 100644) (index d277cce..4d70ad0)
35 35
36 36 namespace fs = boost::filesystem; namespace fs = boost::filesystem;
37 37
38 std::function<GcovImporter::runner_f> GcovImporter::runner;
39
40 38 void void
41 39 GcovImporter::setRunner(std::function<runner_f> runner) GcovImporter::setRunner(std::function<runner_f> runner)
42 40 { {
43 GcovImporter::runner = std::move(runner);
41 getRunner() = std::move(runner);
44 42 } }
45 43
46 44 GcovImporter::GcovImporter(const std::string &root, GcovImporter::GcovImporter(const std::string &root,
 
... ... GcovImporter::GcovImporter(const std::string &root,
88 86
89 87 TempDir tempDir("gcovi"); TempDir tempDir("gcovi");
90 88 std::string tempDirPath = tempDir; std::string tempDirPath = tempDir;
91 runner(std::move(cmd), tempDirPath);
89 getRunner()(std::move(cmd), tempDirPath);
92 90
93 91 for (fs::directory_entry &e : for (fs::directory_entry &e :
94 92 fs::recursive_directory_iterator(tempDirPath)) { fs::recursive_directory_iterator(tempDirPath)) {
 
... ... GcovImporter::isExcluded(boost::filesystem::path path) const
204 202 } }
205 203 return false; return false;
206 204 } }
205
206 std::function<GcovImporter::runner_f> &
207 GcovImporter::getRunner()
208 {
209 static std::function<runner_f> runner;
210 return runner;
211 }
File src/GcovImporter.hpp changed (mode: 100644) (index 26d20d8..aa79b47)
... ... private:
86 86 bool isExcluded(boost::filesystem::path path) const; bool isExcluded(boost::filesystem::path path) const;
87 87
88 88 private: private:
89 //! Runner of external commands.
90 static std::function<runner_f> runner;
89 /**
90 * @brief Retrieves variable holding runner of external commands.
91 *
92 * @returns The runner variable.
93 */
94 static std::function<runner_f> & getRunner();
91 95
92 96 private: private:
93 97 //! Absolute and normalized path of the source repository. //! Absolute and normalized path of the source repository.
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/uncov

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/uncov

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master