From a459db9bf692e11c2d4ecb6047c2878cdcbeb2bd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Sep 2022 13:20:41 -0400 Subject: Use uppercase integer literal suffixes --- include/lv2/midi/midi.h | 4 ++-- include/lv2/options/options.h | 10 +++++----- include/lv2/state/state.h | 6 +++--- plugins/.clang-tidy | 6 +++++- plugins/eg-sampler.lv2/peaks.h | 4 ++-- plugins/eg-sampler.lv2/sampler.c | 2 +- test/.clang-tidy | 6 +++++- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/lv2/midi/midi.h b/include/lv2/midi/midi.h index 8ca5bf2..cef7bc8 100644 --- a/include/lv2/midi/midi.h +++ b/include/lv2/midi/midi.h @@ -202,7 +202,7 @@ lv2_midi_is_system_message(const uint8_t* msg) case 0xFD: return false; default: - return (msg[0] & 0xF0u) == 0xF0u; + return (msg[0] & 0xF0U) == 0xF0U; } } @@ -214,7 +214,7 @@ static inline LV2_Midi_Message_Type lv2_midi_message_type(const uint8_t* msg) { if (lv2_midi_is_voice_message(msg)) { - return (LV2_Midi_Message_Type)(msg[0] & 0xF0u); + return (LV2_Midi_Message_Type)(msg[0] & 0xF0U); } if (lv2_midi_is_system_message(msg)) { diff --git a/include/lv2/options/options.h b/include/lv2/options/options.h index bdbf641..48f7bfb 100644 --- a/include/lv2/options/options.h +++ b/include/lv2/options/options.h @@ -89,11 +89,11 @@ typedef struct { /** A status code for option functions. */ typedef enum { - LV2_OPTIONS_SUCCESS = 0u, /**< Completed successfully. */ - LV2_OPTIONS_ERR_UNKNOWN = 1u, /**< Unknown error. */ - LV2_OPTIONS_ERR_BAD_SUBJECT = 1u << 1u, /**< Invalid/unsupported subject. */ - LV2_OPTIONS_ERR_BAD_KEY = 1u << 2u, /**< Invalid/unsupported key. */ - LV2_OPTIONS_ERR_BAD_VALUE = 1u << 3u /**< Invalid/unsupported value. */ + LV2_OPTIONS_SUCCESS = 0U, /**< Completed successfully. */ + LV2_OPTIONS_ERR_UNKNOWN = 1U, /**< Unknown error. */ + LV2_OPTIONS_ERR_BAD_SUBJECT = 1U << 1U, /**< Invalid/unsupported subject. */ + LV2_OPTIONS_ERR_BAD_KEY = 1U << 2U, /**< Invalid/unsupported key. */ + LV2_OPTIONS_ERR_BAD_VALUE = 1U << 3U /**< Invalid/unsupported value. */ } LV2_Options_Status; /** diff --git a/include/lv2/state/state.h b/include/lv2/state/state.h index 4cbf54d..9c5d9d8 100644 --- a/include/lv2/state/state.h +++ b/include/lv2/state/state.h @@ -69,7 +69,7 @@ typedef enum { Implementations MUST NOT attempt to copy or serialise a non-POD value if they do not understand its type (and thus know how to correctly do so). */ - LV2_STATE_IS_POD = 1u << 0u, + LV2_STATE_IS_POD = 1U << 0U, /** Portable (architecture independent) data. @@ -80,7 +80,7 @@ typedef enum { values MUST NOT depend on architecture-specific properties like endianness or alignment. Portable values MUST NOT contain filenames. */ - LV2_STATE_IS_PORTABLE = 1u << 1u, + LV2_STATE_IS_PORTABLE = 1U << 1U, /** Native data. @@ -91,7 +91,7 @@ typedef enum { most efficient representation possible and not worry about serialisation and portability. */ - LV2_STATE_IS_NATIVE = 1u << 2u + LV2_STATE_IS_NATIVE = 1U << 2U } LV2_State_Flags; /** A status code for state functions. */ diff --git a/plugins/.clang-tidy b/plugins/.clang-tidy index b1adcb3..bff0bfd 100644 --- a/plugins/.clang-tidy +++ b/plugins/.clang-tidy @@ -5,7 +5,6 @@ Checks: > *, -*-magic-numbers, -*-narrowing-conversions, - -*-uppercase-literal-suffix, -altera-*, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, @@ -20,3 +19,8 @@ Checks: > WarningsAsErrors: '*' HeaderFilterRegex: '.*' FormatStyle: file +CheckOptions: + - key: hicpp-uppercase-literal-suffix.NewSuffixes + value: L;U;f + - key: readability-uppercase-literal-suffix.NewSuffixes + value: L;U;f diff --git a/plugins/eg-sampler.lv2/peaks.h b/plugins/eg-sampler.lv2/peaks.h index 7e0997e..47d6616 100644 --- a/plugins/eg-sampler.lv2/peaks.h +++ b/plugins/eg-sampler.lv2/peaks.h @@ -152,11 +152,11 @@ peaks_sender_send(PeaksSender* sender, forge, &vec_frame, sizeof(float), uris->atom_Float); // Calculate how many peaks to send this update - const uint32_t chunk_size = MAX(1u, sender->n_samples / sender->n_peaks); + const uint32_t chunk_size = MAX(1U, sender->n_samples / sender->n_peaks); const uint32_t space = forge->size - forge->offset; const uint32_t remaining = sender->n_peaks - sender->current_offset; const uint32_t n_update = - MIN(remaining, MIN(n_frames / 4u, space / sizeof(float))); + MIN(remaining, MIN(n_frames / 4U, space / sizeof(float))); // Calculate peak (maximum magnitude) for each chunk for (uint32_t i = 0; i < n_update; ++i) { diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 9ec3cf4..d870a07 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -134,7 +134,7 @@ load_sample(LV2_Log_Logger* logger, const char* path, const int sample_rate) return NULL; } - sf_seek(sndfile, 0ul, SEEK_SET); + sf_seek(sndfile, 0UL, SEEK_SET); sf_read_float(sndfile, data, info->frames * info->channels); sf_close(sndfile); diff --git a/test/.clang-tidy b/test/.clang-tidy index 1b74f21..53f37b1 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -5,7 +5,6 @@ Checks: > *, -*-else-after-return, -*-magic-numbers, - -*-uppercase-literal-suffix, -altera-*, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, @@ -21,3 +20,8 @@ Checks: > WarningsAsErrors: '*' HeaderFilterRegex: '.*' FormatStyle: file +CheckOptions: + - key: hicpp-uppercase-literal-suffix.NewSuffixes + value: L;U;f + - key: readability-uppercase-literal-suffix.NewSuffixes + value: L;U;f -- cgit v1.2.1