From d6a3daaa9db81c7f4d58860131a86c83a0c4b508 Mon Sep 17 00:00:00 2001 From: Ivano Bilenchi Date: Tue, 19 Nov 2024 21:51:58 +0100 Subject: [PATCH] Fix Clang 19 warnings --- .clang-tidy | 3 ++- .clangd | 4 +++- .pre-commit-config.yaml | 4 ++-- lib/ulib | 2 +- src/cowl_cstring.c | 2 +- src/cowl_literal.c | 2 +- src/cowl_object.c | 4 ++-- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 6d56616..3365c2b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,9 +16,10 @@ Checks: > -performance-enum-size, portability-*, readability-*, + -readability-enum-initial-value, -readability-identifier-length, -readability-magic-numbers CheckOptions: - misc-include-cleaner.IgnoreHeaders: sys/_types/_size_t\.h + misc-include-cleaner.IgnoreHeaders: /_[^/]+\.h$;^_[^/]+\.h$ readability-braces-around-statements.ShortStatementLines: 2 readability-function-cognitive-complexity.IgnoreMacros: true diff --git a/.clangd b/.clangd index 529a35e..9564fc8 100644 --- a/.clangd +++ b/.clangd @@ -2,4 +2,6 @@ Diagnostics: MissingIncludes: Strict Includes: - IgnoreHeader: sys/_types/_size_t\.h + IgnoreHeader: + - /_[^/]+\.h$ + - ^_[^/]+\.h$ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93f2c33..09e62c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-yaml @@ -8,6 +8,6 @@ repos: - id: mixed-line-ending - id: end-of-file-fixer - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 + rev: v19.1.3 hooks: - id: clang-format diff --git a/lib/ulib b/lib/ulib index adf1697..8da6aec 160000 --- a/lib/ulib +++ b/lib/ulib @@ -1 +1 @@ -Subproject commit adf169717a7c610ba3e27f720107e3ea7587d9dd +Subproject commit 8da6aeccacf5dd478306599a2fc1a88c1324804b diff --git a/src/cowl_cstring.c b/src/cowl_cstring.c index b65f46d..e52f5ea 100644 --- a/src/cowl_cstring.c +++ b/src/cowl_cstring.c @@ -16,7 +16,7 @@ size_t cowl_str_from_uint(ulib_uint uint, char *buf) { char *cur = buf; do { - *(cur++) = (char)(uint % 10 + '0'); + *(cur++) = (char)((uint % 10) + '0'); uint /= 10; } while (uint); diff --git a/src/cowl_literal.c b/src/cowl_literal.c index c6d30ea..8711446 100644 --- a/src/cowl_literal.c +++ b/src/cowl_literal.c @@ -77,7 +77,7 @@ static inline bool is_lang_datatype(CowlDatatype *dt) { } static CowlLiteral *cowl_literal_alloc(CowlDatatype *dt, CowlString *value, CowlString *lang) { - CowlComposite *literal = ulib_malloc(sizeof(*literal) + 2 * sizeof(*literal->fields)); + CowlComposite *literal = ulib_malloc(sizeof(*literal) + (2 * sizeof(*literal->fields))); if (!literal) return NULL; literal->super = COWL_OBJECT_BIT_INIT(COWL_OT_LITERAL, lang); diff --git a/src/cowl_object.c b/src/cowl_object.c index 43568aa..89ae835 100644 --- a/src/cowl_object.c +++ b/src/cowl_object.c @@ -437,7 +437,7 @@ bool cowl_iterate_primitives(CowlAny *object, CowlPrimitiveFlags flags, CowlIter CowlAny *cowl_get_impl(CowlObjectType type, CowlAny *fields[], CowlAny *opt) { ulib_byte const n = type_field_count(type); - CowlComposite *o = ulib_malloc(sizeof(*o) + (opt ? n + 1 : n) * sizeof(*o->fields)); + CowlComposite *o = ulib_malloc(sizeof(*o) + ((opt ? n + 1 : n) * sizeof(*o->fields))); if (!o) return NULL; o->super = COWL_OBJECT_BIT_INIT(type, opt); @@ -457,7 +457,7 @@ CowlAny *cowl_get_impl_annot(CowlObjectType type, CowlAny *fields[], CowlVector CowlAny *cowl_get_impl_uint(CowlObjectType type, CowlAny *fields[], ulib_uint val, CowlAny *opt) { ulib_byte const n = type_field_count(type); ulib_byte data_size = opt ? n + 2 : n + 1; - CowlComposite *obj = ulib_malloc(sizeof(*obj) + data_size * sizeof(*obj->fields)); + CowlComposite *obj = ulib_malloc(sizeof(*obj) + (data_size * sizeof(*obj->fields))); if (!obj) return NULL; obj->super = COWL_OBJECT_BIT_INIT(type, opt);