From 6c79da8a2f4290f0a57de7d45f5e3f10f0d3c40d Mon Sep 17 00:00:00 2001 From: Dorian Stoll Date: Wed, 3 Apr 2024 11:35:27 +0200 Subject: [PATCH] clang-tidy: Fix new warnings from clang / LLVM 18 --- .clang-tidy | 1 + src/common/casts.hpp | 10 +++++----- src/common/constants.hpp | 4 ++-- src/common/reader.hpp | 2 +- src/contacts/detection/algorithms/errors.hpp | 4 +++- src/contacts/detection/algorithms/neutral.hpp | 2 +- src/core/generic/errors.hpp | 4 +++- src/core/linux/errors.hpp | 4 +++- src/hid/errors.hpp | 4 +++- src/hid/report.hpp | 2 +- src/hid/spec.hpp | 8 ++++---- src/ipts/device.hpp | 4 ++-- src/ipts/protocol/legacy.hpp | 1 + 13 files changed, 30 insertions(+), 20 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0c003c14..6b597cf0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -21,6 +21,7 @@ "-readability-redundant-access-specifiers", "-readability-function-cognitive-complexity", "-readability-braces-around-statements", + "-readability-redundant-member-init", ], "HeaderFilterRegex": "src/.*hpp", "FormatStyle": "file", diff --git a/src/common/casts.hpp b/src/common/casts.hpp index 2e584a2a..bf6239c4 100644 --- a/src/common/casts.hpp +++ b/src/common/casts.hpp @@ -17,7 +17,7 @@ namespace iptsd::casts { template -constexpr inline To to(const From value) +constexpr To to(const From value) { static_assert(!std::is_same_v || !std::is_same_v, "f64 to f32 cannot be narrowed safely. Please use gsl::narrow_cast!"); @@ -32,19 +32,19 @@ constexpr inline To to(const From value) } template -constexpr inline std::make_signed_t to_signed(const T value) +constexpr std::make_signed_t to_signed(const T value) { return to>(value); } template -constexpr inline std::make_unsigned_t to_unsigned(const T value) +constexpr std::make_unsigned_t to_unsigned(const T value) { return to>(value); } template -constexpr inline Eigen::Index to_eigen(const T value) +constexpr Eigen::Index to_eigen(const T value) { return to(value); } @@ -57,7 +57,7 @@ constexpr inline Eigen::Index to_eigen(const T value) * @return A copy of the value of the packed field. */ template -constexpr inline T unpack(const T packed) +constexpr T unpack(const T packed) { return packed; } diff --git a/src/common/constants.hpp b/src/common/constants.hpp index c68d1d83..e8a8a762 100644 --- a/src/common/constants.hpp +++ b/src/common/constants.hpp @@ -6,7 +6,7 @@ #include template -constexpr inline T Zero() +constexpr T Zero() { if constexpr (std::is_scalar_v) return static_cast(0); @@ -15,7 +15,7 @@ constexpr inline T Zero() } template -constexpr inline T One() +constexpr T One() { if constexpr (std::is_scalar_v) return static_cast(1); diff --git a/src/common/reader.hpp b/src/common/reader.hpp index d416cec8..455f559d 100644 --- a/src/common/reader.hpp +++ b/src/common/reader.hpp @@ -13,7 +13,7 @@ namespace iptsd { namespace impl { -enum class ReaderError { +enum class ReaderError : u8 { EndOfBuffer, }; diff --git a/src/contacts/detection/algorithms/errors.hpp b/src/contacts/detection/algorithms/errors.hpp index 6dc81eba..f09ed48e 100644 --- a/src/contacts/detection/algorithms/errors.hpp +++ b/src/contacts/detection/algorithms/errors.hpp @@ -3,11 +3,13 @@ #ifndef IPTSD_CONTACTS_DETECTION_ALGORITHMS_ERRORS_HPP #define IPTSD_CONTACTS_DETECTION_ALGORITHMS_ERRORS_HPP +#include + #include namespace iptsd::contacts::detection { -enum class Error { +enum class Error : u8 { InvalidNeutralMode, InvalidClusterOverlap, FailedToMergeClusters, diff --git a/src/contacts/detection/algorithms/neutral.hpp b/src/contacts/detection/algorithms/neutral.hpp index 29f77121..eaf7414c 100644 --- a/src/contacts/detection/algorithms/neutral.hpp +++ b/src/contacts/detection/algorithms/neutral.hpp @@ -51,7 +51,7 @@ typename DenseBase::Scalar statistical_mode(const DenseBase &d /* * The algorithm that will be used to calculate the neutral value. */ -enum class Algorithm { +enum class Algorithm : u8 { // The most common element (statistical mode) will be used. MODE, diff --git a/src/core/generic/errors.hpp b/src/core/generic/errors.hpp index adb69a02..ee63cd6e 100644 --- a/src/core/generic/errors.hpp +++ b/src/core/generic/errors.hpp @@ -3,11 +3,13 @@ #ifndef IPTSD_CORE_GENERIC_ERRORS_HPP #define IPTSD_CORE_GENERIC_ERRORS_HPP +#include + #include namespace iptsd::core { -enum class Error { +enum class Error : u8 { InvalidScreenSize, InvalidNeutralValueAlgorithm, }; diff --git a/src/core/linux/errors.hpp b/src/core/linux/errors.hpp index 80a44781..12f8c893 100644 --- a/src/core/linux/errors.hpp +++ b/src/core/linux/errors.hpp @@ -3,11 +3,13 @@ #ifndef IPTSD_CORE_LINUX_ERRORS_HPP #define IPTSD_CORE_LINUX_ERRORS_HPP +#include + #include namespace iptsd::core::linux { -enum class Error { +enum class Error : u8 { ParsingFailed, ParsingTypeNotImplemented, RunnerInitError, diff --git a/src/hid/errors.hpp b/src/hid/errors.hpp index e572de09..96779766 100644 --- a/src/hid/errors.hpp +++ b/src/hid/errors.hpp @@ -3,11 +3,13 @@ #ifndef IPTSD_HID_ERRORS_HPP #define IPTSD_HID_ERRORS_HPP +#include + #include namespace iptsd::hid { -enum class Error { +enum class Error : u8 { ReportMergeTypes, ReportMergeIDs, UsageBeforePage, diff --git a/src/hid/report.hpp b/src/hid/report.hpp index 142a7b0c..ed3e273b 100644 --- a/src/hid/report.hpp +++ b/src/hid/report.hpp @@ -19,7 +19,7 @@ namespace iptsd::hid { /* * The type of a report. */ -enum class ReportType { +enum class ReportType : u8 { // Data that is coming from the device Input, diff --git a/src/hid/spec.hpp b/src/hid/spec.hpp index d022c545..236dd000 100644 --- a/src/hid/spec.hpp +++ b/src/hid/spec.hpp @@ -18,7 +18,7 @@ constexpr static u8 SHIFT_SIZE = 0; /* * 6.2.2.2 Short Items */ -enum class ItemType { +enum class ItemType : u8 { Main = 0, Global = 1, Local = 2, @@ -28,7 +28,7 @@ enum class ItemType { /* * 6.2.2.4 Main Items */ -enum class TagMain { +enum class TagMain : u8 { Input = 0b1000, Output = 0b1001, Feature = 0b1011, @@ -36,14 +36,14 @@ enum class TagMain { EndCollection = 0b1100, }; -enum class TagGlobal { +enum class TagGlobal : u8 { UsagePage = 0b0000, ReportSize = 0b0111, ReportId = 0b1000, ReportCount = 0b1001, }; -enum class TagLocal { +enum class TagLocal : u8 { Usage = 0b0000, UsageMinimum = 0b0001, UsageMaximum = 0b0010, diff --git a/src/ipts/device.hpp b/src/ipts/device.hpp index 4e3f8892..c8376a77 100644 --- a/src/ipts/device.hpp +++ b/src/ipts/device.hpp @@ -23,7 +23,7 @@ namespace iptsd::ipts { namespace impl { -enum class DeviceError { +enum class DeviceError : u8 { InvalidDevice, InvalidSetModeReport, }; @@ -42,7 +42,7 @@ inline std::string format_as(DeviceError err) } // namespace impl -enum class Mode { +enum class Mode : u8 { Singletouch = 0, Multitouch = 1, }; diff --git a/src/ipts/protocol/legacy.hpp b/src/ipts/protocol/legacy.hpp index c02eaf5c..245b6f2c 100644 --- a/src/ipts/protocol/legacy.hpp +++ b/src/ipts/protocol/legacy.hpp @@ -32,6 +32,7 @@ struct [[gnu::packed]] Header { }; static_assert(sizeof(Header) == 12); +// NOLINTNEXTLINE(performance-enum-size) enum class GroupType : u16 { //! The group contains report frames with stylus data. Stylus = 0x6,