From 1431c92bc6260a2869c57bc7126770a05fda3456 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 25 Oct 2017 22:56:11 +0200 Subject: [PATCH] Add some "explicit" keyword (sonar, codacy). --- include/xbt/Extendable.hpp | 6 +++--- include/xbt/exception.hpp | 5 ++--- include/xbt/range.hpp | 4 ++-- include/xbt/string.hpp | 2 +- src/mc/DwarfExpression.hpp | 2 +- src/mc/LocationList.hpp | 4 +++- src/mc/mc_dwarf.cpp | 2 +- src/mc/mc_state.hpp | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/xbt/Extendable.hpp b/include/xbt/Extendable.hpp index 1da9b31238..785e337546 100644 --- a/include/xbt/Extendable.hpp +++ b/include/xbt/Extendable.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. +/* Copyright (c) 2015, 2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ class Extension { static const std::size_t INVALID_ID = std::numeric_limits::max(); std::size_t id_; friend class Extendable; - constexpr Extension(std::size_t id) : id_(id) {} + explicit constexpr Extension(std::size_t id) : id_(id) {} public: explicit constexpr Extension() : id_(INVALID_ID) {} std::size_t id() const { return id_; } @@ -64,7 +64,7 @@ public: template static Extension extension_create() { - return extension_create([](void* p){ delete static_cast(p); }); + return Extension(extension_create([](void* p) { delete static_cast(p); })); } Extendable() : extensions_(deleters_.size(), nullptr) {} ~Extendable() diff --git a/include/xbt/exception.hpp b/include/xbt/exception.hpp index 7c826cd697..3d648a1b65 100644 --- a/include/xbt/exception.hpp +++ b/include/xbt/exception.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2005-2016. The SimGrid Team.All rights reserved. */ +/* Copyright (c) 2005-2017. The SimGrid Team.All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -99,8 +99,7 @@ class WithContext : public E, public WithContextException public: static_assert(not std::is_base_of::value, "Trying to appli WithContext twice"); - WithContext(E exception) : - E(std::move(exception)) {} + explicit WithContext(E exception) : E(std::move(exception)) {} WithContext(E exception, ThrowPoint throwpoint, Backtrace backtrace) : E(std::move(exception)), WithContextException(throwpoint, std::move(backtrace)) {} diff --git a/include/xbt/range.hpp b/include/xbt/range.hpp index 5c20a9c866..be1e7e8628 100644 --- a/include/xbt/range.hpp +++ b/include/xbt/range.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016. The SimGrid Team. +/* Copyright (c) 2016-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -17,7 +17,7 @@ template class Range { public: Range() : begin_(), end_() {} Range(T begin, T end) : begin_(std::move(begin)), end_(std::move(end)) {} - Range(T value) : begin_(value), end_(value + 1) {} + explicit Range(T value) : begin_(value), end_(value + 1) {} T& begin() { return begin_; } T& end() { return end_; } const T& begin() const { return begin_; } diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index ae6728ce78..e610b816b8 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -98,7 +98,7 @@ public: s.string_data::len = 0; s.string_data::data = &NUL; } - string(std::string const& s) : string(s.c_str(), s.size()) {} + explicit string(std::string const& s) : string(s.c_str(), s.size()) {} // Assign void assign(const char* s, size_t size) diff --git a/src/mc/DwarfExpression.hpp b/src/mc/DwarfExpression.hpp index defb89ceb6..38bcbcac98 100644 --- a/src/mc/DwarfExpression.hpp +++ b/src/mc/DwarfExpression.hpp @@ -58,7 +58,7 @@ public: /** When an error happens in the execution of a DWARF expression */ class evaluation_error : std::runtime_error { public: - evaluation_error(const char* what): std::runtime_error(what) {} + explicit evaluation_error(const char* what) : std::runtime_error(what) {} }; /** A stack for evaluating a DWARF expression diff --git a/src/mc/LocationList.hpp b/src/mc/LocationList.hpp index 8e4aee3a4f..807291e9fe 100644 --- a/src/mc/LocationList.hpp +++ b/src/mc/LocationList.hpp @@ -37,7 +37,9 @@ public: LocationListEntry(DwarfExpression expression, range_type range) : expression_(std::move(expression)), range_(range) {} - LocationListEntry(DwarfExpression expression) : expression_(std::move(expression)), range_({0, UINT64_MAX}) {} + explicit LocationListEntry(DwarfExpression expression) : expression_(std::move(expression)), range_({0, UINT64_MAX}) + { + } DwarfExpression& expression() { diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index 88e1369519..5e95580971 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -776,7 +776,7 @@ static std::unique_ptr MC_die_to_variable( variable->address = (void *) (base + offset); } else variable->location_list = { - simgrid::dwarf::DwarfExpression(expr, expr + len) }; + simgrid::dwarf::LocationListEntry(simgrid::dwarf::DwarfExpression(expr, expr + len))}; break; } diff --git a/src/mc/mc_state.hpp b/src/mc/mc_state.hpp index edef946f08..d14e7fd9d4 100644 --- a/src/mc/mc_state.hpp +++ b/src/mc/mc_state.hpp @@ -125,7 +125,7 @@ public: std::vector> incomplete_comm_pattern; std::vector communicationIndices; - State(unsigned long state_number); + explicit State(unsigned long state_number); std::size_t interleaveSize() const; void addInterleavingSet(smx_actor_t actor) { this->actorStates[actor->pid].consider(); } -- 2.20.1