From 09f40d2e1e5f987b97410535435a7a1db7323511 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Oct 2022 21:48:43 -0400 Subject: Use uppercase integer literal suffixes --- .clang-tidy | 1 - include/serd/serd.h | 30 ++++++++++---------- src/n3.c | 6 ++-- src/node.c | 4 +-- src/serdi.c | 2 +- src/stack.h | 2 +- src/string_utils.h | 72 ++++++++++++++++++++++++------------------------ test/headers/.clang-tidy | 1 - 8 files changed, 58 insertions(+), 60 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index e7f1ca66..eaf6ac95 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,7 +3,6 @@ Checks: > *, - -*-uppercase-literal-suffix, -altera-*, -llvmlibc-*, -readability-identifier-length, diff --git a/include/serd/serd.h b/include/serd/serd.h index fbadff9b..0e1913f8 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -83,8 +83,8 @@ typedef enum { /// Flags indicating certain string properties relevant to serialisation typedef enum { - SERD_HAS_NEWLINE = 1u << 0u, ///< Contains line breaks ('\\n' or '\\r') - SERD_HAS_QUOTE = 1u << 1u ///< Contains quotes ('"') + SERD_HAS_NEWLINE = 1U << 0U, ///< Contains line breaks ('\\n' or '\\r') + SERD_HAS_QUOTE = 1U << 1U ///< Contains quotes ('"') } SerdNodeFlag; /// Bitwise OR of SerdNodeFlag values @@ -543,14 +543,14 @@ serd_node_free(SerdNode* SERD_NULLABLE node); /// Flags indicating inline abbreviation information for a statement typedef enum { - SERD_EMPTY_S = 1u << 1u, ///< Empty blank node subject - SERD_EMPTY_O = 1u << 2u, ///< Empty blank node object - SERD_ANON_S_BEGIN = 1u << 3u, ///< Start of anonymous subject - SERD_ANON_O_BEGIN = 1u << 4u, ///< Start of anonymous object - SERD_ANON_CONT = 1u << 5u, ///< Continuation of anonymous node - SERD_LIST_S_BEGIN = 1u << 6u, ///< Start of list subject - SERD_LIST_O_BEGIN = 1u << 7u, ///< Start of list object - SERD_LIST_CONT = 1u << 8u ///< Continuation of list + SERD_EMPTY_S = 1U << 1U, ///< Empty blank node subject + SERD_EMPTY_O = 1U << 2U, ///< Empty blank node object + SERD_ANON_S_BEGIN = 1U << 3U, ///< Start of anonymous subject + SERD_ANON_O_BEGIN = 1U << 4U, ///< Start of anonymous object + SERD_ANON_CONT = 1U << 5U, ///< Continuation of anonymous node + SERD_LIST_S_BEGIN = 1U << 6U, ///< Start of list subject + SERD_LIST_O_BEGIN = 1U << 7U, ///< Start of list object + SERD_LIST_CONT = 1U << 8U ///< Continuation of list } SerdStatementFlag; /// Bitwise OR of SerdStatementFlag values @@ -878,11 +878,11 @@ typedef struct SerdWriterImpl SerdWriter; does not support abbreviation and is always ASCII. */ typedef enum { - SERD_STYLE_ABBREVIATED = 1u << 0u, ///< Abbreviate triples when possible. - SERD_STYLE_ASCII = 1u << 1u, ///< Escape all non-ASCII characters. - SERD_STYLE_RESOLVED = 1u << 2u, ///< Resolve URIs against base URI. - SERD_STYLE_CURIED = 1u << 3u, ///< Shorten URIs into CURIEs. - SERD_STYLE_BULK = 1u << 4u, ///< Write output in pages. + SERD_STYLE_ABBREVIATED = 1U << 0U, ///< Abbreviate triples when possible. + SERD_STYLE_ASCII = 1U << 1U, ///< Escape all non-ASCII characters. + SERD_STYLE_RESOLVED = 1U << 2U, ///< Resolve URIs against base URI. + SERD_STYLE_CURIED = 1U << 3U, ///< Shorten URIs into CURIEs. + SERD_STYLE_BULK = 1U << 4U, ///< Write output in pages. } SerdStyle; /// Create a new RDF writer diff --git a/src/n3.c b/src/n3.c index fd26d69f..2cbfb55a 100644 --- a/src/n3.c +++ b/src/n3.c @@ -112,17 +112,17 @@ read_UCHAR(SerdReader* const reader, const Ref dest, uint32_t* const char_code) uint32_t c = code; switch (size) { case 4: - buf[3] = (uint8_t)(0x80u | (c & 0x3Fu)); + buf[3] = (uint8_t)(0x80U | (c & 0x3FU)); c >>= 6; c |= (16 << 12); // set bit 4 SERD_FALLTHROUGH; case 3: - buf[2] = (uint8_t)(0x80u | (c & 0x3Fu)); + buf[2] = (uint8_t)(0x80U | (c & 0x3FU)); c >>= 6; c |= (32 << 6); // set bit 5 SERD_FALLTHROUGH; case 2: - buf[1] = (uint8_t)(0x80u | (c & 0x3Fu)); + buf[1] = (uint8_t)(0x80U | (c & 0x3FU)); c >>= 6; c |= 0xC0; // set bits 6 and 7 SERD_FALLTHROUGH; diff --git a/src/node.c b/src/node.c index 11a37139..f3c28cea 100644 --- a/src/node.c +++ b/src/node.c @@ -323,7 +323,7 @@ serd_node_new_decimal(const double d, const unsigned frac_digits) for (; i < frac_digits - 1 && !(frac % 10); ++i, --s, frac /= 10) { } - node.n_bytes = node.n_chars = (size_t)(s - buf) + 1u; + node.n_bytes = node.n_chars = (size_t)(s - buf) + 1U; // Write digits from last trailing zero to decimal point for (; i < frac_digits; ++i) { @@ -350,7 +350,7 @@ serd_node_new_integer(const int64_t i) ++s; } - node.n_bytes = node.n_chars = (size_t)(s - buf) + 1u; + node.n_bytes = node.n_chars = (size_t)(s - buf) + 1U; // Write integer part (right to left) do { diff --git a/src/serdi.c b/src/serdi.c index 34da4536..f3f7ca54 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -145,7 +145,7 @@ choose_style(const SerdSyntax input_syntax, const bool bulk_write, const bool full_uris) { - unsigned output_style = 0u; + unsigned output_style = 0U; if (output_syntax == SERD_NTRIPLES || ascii) { output_style |= SERD_STYLE_ASCII; } else if (output_syntax == SERD_TURTLE) { diff --git a/src/stack.h b/src/stack.h index ceb41ad5..5040ace5 100644 --- a/src/stack.h +++ b/src/stack.h @@ -100,7 +100,7 @@ serd_stack_pop_aligned(SerdStack* stack, size_t n_bytes) const uint8_t pad = stack->buf[stack->size - 1]; // Pop padding and pad count - serd_stack_pop(stack, pad + 1u); + serd_stack_pop(stack, pad + 1U); } #endif // SERD_STACK_H diff --git a/src/string_utils.h b/src/string_utils.h index dec6ed2f..2fcfadac 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -111,50 +111,50 @@ static inline uint32_t utf8_num_bytes(const uint8_t leading) { static const uint8_t lengths[32] = { - 1u, // 00000xxx - 1u, // 00001xxx - 1u, // 00010xxx - 1u, // 00011xxx - 1u, // 00100xxx - 1u, // 00101xxx - 1u, // 00110xxx - 1u, // 00111xxx - 1u, // 01000xxx - 1u, // 01001xxx - 1u, // 01010xxx - 1u, // 01011xxx - 1u, // 01100xxx - 1u, // 01101xxx - 1u, // 01110xxx - 1u, // 01111xxx - 0u, // 10000xxx - 0u, // 10001xxx - 0u, // 10010xxx - 0u, // 10011xxx - 0u, // 10100xxx - 0u, // 10101xxx - 0u, // 10110xxx - 0u, // 10111xxx - 2u, // 11000xxx - 2u, // 11001xxx - 2u, // 11010xxx - 2u, // 11011xxx - 3u, // 11100xxx - 3u, // 11101xxx - 4u, // 11110xxx - 0u // 11111xxx + 1U, // 00000xxx + 1U, // 00001xxx + 1U, // 00010xxx + 1U, // 00011xxx + 1U, // 00100xxx + 1U, // 00101xxx + 1U, // 00110xxx + 1U, // 00111xxx + 1U, // 01000xxx + 1U, // 01001xxx + 1U, // 01010xxx + 1U, // 01011xxx + 1U, // 01100xxx + 1U, // 01101xxx + 1U, // 01110xxx + 1U, // 01111xxx + 0U, // 10000xxx + 0U, // 10001xxx + 0U, // 10010xxx + 0U, // 10011xxx + 0U, // 10100xxx + 0U, // 10101xxx + 0U, // 10110xxx + 0U, // 10111xxx + 2U, // 11000xxx + 2U, // 11001xxx + 2U, // 11010xxx + 2U, // 11011xxx + 3U, // 11100xxx + 3U, // 11101xxx + 4U, // 11110xxx + 0U // 11111xxx }; - return lengths[leading >> 3u]; + return lengths[leading >> 3U]; } /// Return the code point of a UTF-8 character with known length static inline uint32_t parse_counted_utf8_char(const uint8_t* utf8, size_t size) { - uint32_t c = utf8[0] & ((1u << (8u - size)) - 1u); + uint32_t c = utf8[0] & ((1U << (8U - size)) - 1U); for (size_t i = 1; i < size; ++i) { - c = (c << 6) | (utf8[i] & 0x3Fu); + c = (c << 6) | (utf8[i] & 0x3FU); } return c; } @@ -171,7 +171,7 @@ parse_utf8_char(const uint8_t* utf8, size_t* size) return parse_counted_utf8_char(utf8, *size); default: *size = 0; - return 0u; + return 0U; } } diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy index e7f1ca66..eaf6ac95 100644 --- a/test/headers/.clang-tidy +++ b/test/headers/.clang-tidy @@ -3,7 +3,6 @@ Checks: > *, - -*-uppercase-literal-suffix, -altera-*, -llvmlibc-*, -readability-identifier-length, -- cgit v1.2.1