1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-22 15:54:57 +00:00

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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 7 deletions

View file

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

View file

@ -23,13 +23,14 @@ class Flags
{
public:
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>);
public:
constexpr Flags() noexcept = default;
// NOLINTNEXTLINE(hicpp-explicit-conversions)
constexpr Flags(FlagType flag) noexcept
{
set(flag);

View file

@ -17,7 +17,7 @@ class Session;
class FreeSpaceLabel : public Gtk::Label
{
public:
FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string_view dir = {});
explicit FreeSpaceLabel(Glib::RefPtr<Session> const& core, std::string_view dir = {});
FreeSpaceLabel(
BaseObjectType* cast_item,
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 })
{
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)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
// NOLINTNEXTLINE(*-vararg)
g_message("%s", message.c_str());
}
void gtr_warning(std::string const& message)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
// NOLINTNEXTLINE(*-vararg)
g_warning("%s", message.c_str());
}
void gtr_error(std::string const& message)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
// NOLINTNEXTLINE(*-vararg)
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)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
// NOLINTNEXTLINE(*-vararg)
g_signal_emit_by_name(object.gobj(), "notify", nullptr);
}