Skip to content

Commit

Permalink
clang-tidy: Fix new warnings from clang / LLVM 18
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Apr 3, 2024
1 parent 158b609 commit 6c79da8
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 20 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/common/casts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace iptsd::casts {

template <class To, class From>
constexpr inline To to(const From value)
constexpr To to(const From value)
{
static_assert(!std::is_same_v<From, f64> || !std::is_same_v<To, f32>,
"f64 to f32 cannot be narrowed safely. Please use gsl::narrow_cast!");
Expand All @@ -32,19 +32,19 @@ constexpr inline To to(const From value)
}

template <class T>
constexpr inline std::make_signed_t<T> to_signed(const T value)
constexpr std::make_signed_t<T> to_signed(const T value)
{
return to<std::make_signed_t<T>>(value);
}

template <class T>
constexpr inline std::make_unsigned_t<T> to_unsigned(const T value)
constexpr std::make_unsigned_t<T> to_unsigned(const T value)
{
return to<std::make_unsigned_t<T>>(value);
}

template <class T>
constexpr inline Eigen::Index to_eigen(const T value)
constexpr Eigen::Index to_eigen(const T value)
{
return to<Eigen::Index>(value);
}
Expand All @@ -57,7 +57,7 @@ constexpr inline Eigen::Index to_eigen(const T value)
* @return A copy of the value of the packed field.
*/
template <class T>
constexpr inline T unpack(const T packed)
constexpr T unpack(const T packed)
{
return packed;
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <type_traits>

template <class T>
constexpr inline T Zero()
constexpr T Zero()
{
if constexpr (std::is_scalar_v<T>)
return static_cast<T>(0);
Expand All @@ -15,7 +15,7 @@ constexpr inline T Zero()
}

template <class T>
constexpr inline T One()
constexpr T One()
{
if constexpr (std::is_scalar_v<T>)
return static_cast<T>(1);
Expand Down
2 changes: 1 addition & 1 deletion src/common/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace iptsd {
namespace impl {

enum class ReaderError {
enum class ReaderError : u8 {
EndOfBuffer,
};

Expand Down
4 changes: 3 additions & 1 deletion src/contacts/detection/algorithms/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#ifndef IPTSD_CONTACTS_DETECTION_ALGORITHMS_ERRORS_HPP
#define IPTSD_CONTACTS_DETECTION_ALGORITHMS_ERRORS_HPP

#include <common/types.hpp>

#include <string>

namespace iptsd::contacts::detection {

enum class Error {
enum class Error : u8 {
InvalidNeutralMode,
InvalidClusterOverlap,
FailedToMergeClusters,
Expand Down
2 changes: 1 addition & 1 deletion src/contacts/detection/algorithms/neutral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typename DenseBase<Derived>::Scalar statistical_mode(const DenseBase<Derived> &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,

Expand Down
4 changes: 3 additions & 1 deletion src/core/generic/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#ifndef IPTSD_CORE_GENERIC_ERRORS_HPP
#define IPTSD_CORE_GENERIC_ERRORS_HPP

#include <common/types.hpp>

#include <string>

namespace iptsd::core {

enum class Error {
enum class Error : u8 {
InvalidScreenSize,
InvalidNeutralValueAlgorithm,
};
Expand Down
4 changes: 3 additions & 1 deletion src/core/linux/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#ifndef IPTSD_CORE_LINUX_ERRORS_HPP
#define IPTSD_CORE_LINUX_ERRORS_HPP

#include <common/types.hpp>

#include <string>

namespace iptsd::core::linux {

enum class Error {
enum class Error : u8 {
ParsingFailed,
ParsingTypeNotImplemented,
RunnerInitError,
Expand Down
4 changes: 3 additions & 1 deletion src/hid/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#ifndef IPTSD_HID_ERRORS_HPP
#define IPTSD_HID_ERRORS_HPP

#include <common/types.hpp>

#include <string>

namespace iptsd::hid {

enum class Error {
enum class Error : u8 {
ReportMergeTypes,
ReportMergeIDs,
UsageBeforePage,
Expand Down
2 changes: 1 addition & 1 deletion src/hid/report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
8 changes: 4 additions & 4 deletions src/hid/spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,22 +28,22 @@ enum class ItemType {
/*
* 6.2.2.4 Main Items
*/
enum class TagMain {
enum class TagMain : u8 {
Input = 0b1000,
Output = 0b1001,
Feature = 0b1011,
Collection = 0b1010,
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,
Expand Down
4 changes: 2 additions & 2 deletions src/ipts/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace iptsd::ipts {
namespace impl {

enum class DeviceError {
enum class DeviceError : u8 {
InvalidDevice,
InvalidSetModeReport,
};
Expand All @@ -42,7 +42,7 @@ inline std::string format_as(DeviceError err)

} // namespace impl

enum class Mode {
enum class Mode : u8 {
Singletouch = 0,
Multitouch = 1,
};
Expand Down
1 change: 1 addition & 0 deletions src/ipts/protocol/legacy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6c79da8

Please sign in to comment.