Skip to content

Commit

Permalink
Fix Clang 19 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Nov 19, 2024
1 parent fbd89e6 commit d6a3daa
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
Diagnostics:
MissingIncludes: Strict
Includes:
IgnoreHeader: sys/_types/_size_t\.h
IgnoreHeader:
- /_[^/]+\.h$
- ^_[^/]+\.h$
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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
- id: trailing-whitespace
- 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
2 changes: 1 addition & 1 deletion lib/ulib
2 changes: 1 addition & 1 deletion src/cowl_cstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/cowl_literal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/cowl_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d6a3daa

Please sign in to comment.