diff options
author | David Robillard <d@drobilla.net> | 2024-12-10 10:11:53 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-12-11 00:19:20 -0500 |
commit | 8dd6fe5d29d448ec654b70a7fee61047d51db0ac (patch) | |
tree | 55d3646daa583d3130c653fcc29d709f3d8ca601 /src | |
parent | 1e2f1466262ef571764bec2b95e466763d468ae3 (diff) | |
download | zix-8dd6fe5d29d448ec654b70a7fee61047d51db0ac.tar.gz zix-8dd6fe5d29d448ec654b70a7fee61047d51db0ac.tar.bz2 zix-8dd6fe5d29d448ec654b70a7fee61047d51db0ac.zip |
Fix widening conversions after arithmetic
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 12 | ||||
-rw-r--r-- | src/ring.c | 4 | ||||
-rw-r--r-- | src/win32/environment_win32.c | 2 | ||||
-rw-r--r-- | src/win32/filesystem_win32.c | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/src/btree.c b/src/btree.c index b762067..f276e5f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1,4 +1,4 @@ -// Copyright 2011-2021 David Robillard <d@drobilla.net> +// Copyright 2011-2024 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #include <zix/btree.h> @@ -199,7 +199,7 @@ zix_btree_ainsert(void** const array, const unsigned i, void* const e) { - memmove(array + i + 1U, array + i, (n - i) * sizeof(e)); + memmove(array + i + 1U, array + i, ((size_t)n - i) * sizeof(e)); array[i] = e; } @@ -208,7 +208,7 @@ static void* zix_btree_aerase(void** const array, const unsigned n, const unsigned i) { void* const ret = array[i]; - memmove(array + i, array + i + 1U, (n - i) * sizeof(ret)); + memmove(array + i, array + i + 1U, ((size_t)n - i) * sizeof(ret)); return ret; } @@ -250,7 +250,7 @@ zix_btree_split_child(ZixAllocator* const allocator, rhs->n_vals * sizeof(void*)); memcpy(rhs->data.inode.children, lhs->data.inode.children + lhs->n_vals + 1U, - (rhs->n_vals + 1U) * sizeof(ZixBTreeNode*)); + ((size_t)rhs->n_vals + 1U) * sizeof(ZixBTreeNode*)); // Move middle value up to parent zix_btree_ainsert( @@ -620,7 +620,7 @@ zix_btree_merge(ZixBTree* const t, ZixBTreeNode* const n, const unsigned i) rhs->n_vals * sizeof(void*)); memcpy(lhs->data.inode.children + lhs->n_vals, rhs->data.inode.children, - (rhs->n_vals + 1U) * sizeof(void*)); + ((size_t)rhs->n_vals + 1U) * sizeof(void*)); } lhs->n_vals += rhs->n_vals; @@ -962,7 +962,7 @@ zix_btree_end(const ZixBTree* const t) bool zix_btree_iter_equals(const ZixBTreeIter lhs, const ZixBTreeIter rhs) { - const size_t indexes_size = (lhs.level + 1U) * sizeof(uint16_t); + const size_t indexes_size = ((size_t)lhs.level + 1U) * sizeof(uint16_t); return (lhs.level == rhs.level) && (lhs.nodes[0U] == rhs.nodes[0U]) && (!lhs.nodes[0U] || !memcmp(lhs.indexes, rhs.indexes, indexes_size)); @@ -1,4 +1,4 @@ -// Copyright 2011-2022 David Robillard <d@drobilla.net> +// Copyright 2011-2024 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #include <zix/ring.h> @@ -190,7 +190,7 @@ peek_internal(const ZixRing* const ring, } else { const uint32_t first_size = ring->size - r; memcpy(dst, &ring->buf[r], first_size); - memcpy((char*)dst + first_size, &ring->buf[0], size - first_size); + memcpy((char*)dst + first_size, &ring->buf[0], (size_t)size - first_size); } return size; diff --git a/src/win32/environment_win32.c b/src/win32/environment_win32.c index e7a0ee3..64feee5 100644 --- a/src/win32/environment_win32.c +++ b/src/win32/environment_win32.c @@ -14,7 +14,7 @@ zix_expand_environment_strings(ZixAllocator* const allocator, return NULL; } - char* const out = (char*)zix_calloc(allocator, 1U, size + 1U); + char* const out = (char*)zix_calloc(allocator, (size_t)size + 1U, 1U); if (out) { ExpandEnvironmentStrings(string, out, size + 1U); } diff --git a/src/win32/filesystem_win32.c b/src/win32/filesystem_win32.c index a790264..877e717 100644 --- a/src/win32/filesystem_win32.c +++ b/src/win32/filesystem_win32.c @@ -1,4 +1,4 @@ -// Copyright 2007-2022 David Robillard <d@drobilla.net> +// Copyright 2007-2024 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #include <zix/filesystem.h> @@ -205,7 +205,7 @@ zix_canonical_path(ZixAllocator* const allocator, const char* const path) return NULL; } - char* const final = (char*)zix_calloc(allocator, final_size + 1U, 1U); + char* const final = (char*)zix_calloc(allocator, (size_t)final_size + 1U, 1U); if (!final || !GetFinalPathNameByHandle(h, final, final_size + 1U, flags)) { zix_free(allocator, final); CloseHandle(h); |