Fix issues reported by hicpp clang-tidy checks (GTK client) (#4711)

* Fix `hicpp-vararg` clang-tidy issues

* Fix `hicpp-explicit-conversions` clang-tidy issues

* Fix `hicpp-signed-bitwise` clang-tidy issues

* Enable the rest of `hicpp` clang-tidy checks
This commit is contained in:
Mike Gelfand
2023-02-03 19:12:48 +03:00
committed by GitHub
parent 3c11b36bc3
commit fbb98ada4a
5 changed files with 9 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ Checks: >
-cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-narrowing-conversions,
hicpp-*,
misc-*, misc-*,
modernize-*, modernize-*,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,

View File

@@ -23,13 +23,14 @@ class Flags
{ {
public: public:
using FlagType = T; using FlagType = T;
using ValueType = std::underlying_type_t<FlagType>; using ValueType = std::make_unsigned_t<std::underlying_type_t<FlagType>>;
static_assert(std::is_enum_v<FlagType> && !std::is_convertible_v<FlagType, ValueType>); static_assert(std::is_enum_v<FlagType> && !std::is_convertible_v<FlagType, ValueType>);
public: public:
constexpr Flags() noexcept = default; constexpr Flags() noexcept = default;
// NOLINTNEXTLINE(hicpp-explicit-conversions)
constexpr Flags(FlagType flag) noexcept constexpr Flags(FlagType flag) noexcept
{ {
set(flag); set(flag);

View File

@@ -17,7 +17,7 @@ class Session;
class FreeSpaceLabel : public Gtk::Label class FreeSpaceLabel : public Gtk::Label
{ {
public: public:
FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string_view dir = {}); explicit FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string_view dir = {});
FreeSpaceLabel( FreeSpaceLabel(
BaseObjectType* cast_item, BaseObjectType* cast_item,
Glib::RefPtr<Gtk::Builder> const& builder, Glib::RefPtr<Gtk::Builder> const& builder,

View File

@@ -58,7 +58,7 @@ unsigned int build_torrent_trackers_hash(tr_torrent const& torrent)
{ {
for (auto const ch : std::string_view{ tr_torrentTracker(&torrent, i).announce }) for (auto const ch : std::string_view{ tr_torrentTracker(&torrent, i).announce })
{ {
hash = (hash << 4) ^ (hash >> 28) ^ ch; hash = (hash << 4U) ^ (hash >> 28U) ^ static_cast<unsigned char>(ch);
} }
} }

View File

@@ -86,19 +86,19 @@ char const* const speed_T_str = N_("TB/s");
void gtr_message(std::string const& message) void gtr_message(std::string const& message)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) // NOLINTNEXTLINE(*-vararg)
g_message("%s", message.c_str()); g_message("%s", message.c_str());
} }
void gtr_warning(std::string const& message) void gtr_warning(std::string const& message)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) // NOLINTNEXTLINE(*-vararg)
g_warning("%s", message.c_str()); g_warning("%s", message.c_str());
} }
void gtr_error(std::string const& message) void gtr_error(std::string const& message)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) // NOLINTNEXTLINE(*-vararg)
g_error("%s", message.c_str()); g_error("%s", message.c_str());
} }
@@ -488,7 +488,7 @@ Glib::SignalProxy<TrObjectSignalNotifyCallback> gtr_object_signal_notify(Glib::O
void gtr_object_notify_emit(Glib::ObjectBase& object) void gtr_object_notify_emit(Glib::ObjectBase& object)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) // NOLINTNEXTLINE(*-vararg)
g_signal_emit_by_name(object.gobj(), "notify", nullptr); g_signal_emit_by_name(object.gobj(), "notify", nullptr);
} }