Skip to content

Commit ac38868

Browse files
authored
fix: CodeQL reported printf format specifier issues (microsoft#480)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
1 parent 57f2e77 commit ac38868

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/rust-clippy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ jobs:
4545
run:
4646
cargo clippy
4747
--all-features
48-
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
4948
--frozen
49+
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
50+
5051
continue-on-error: true
5152

5253
- name: Upload analysis results to GitHub

mimalloc/mimalloc-sys/mimalloc/src/arena.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,12 +623,12 @@ void _mi_arena_free(void* p, size_t size, size_t committed_size, mi_memid_t memi
623623

624624
// checks
625625
if (arena == NULL) {
626-
_mi_error_message(EINVAL, "trying to free from non-existent arena: %p, size %zu, memid: 0x%zx\n", p, size, memid);
626+
_mi_error_message(EINVAL, "trying to free from non-existent arena: %p, size %zu, memid: 0x%zx\n", p, size, (size_t)*(uintptr_t*)&memid);
627627
return;
628628
}
629629
mi_assert_internal(arena->field_count > mi_bitmap_index_field(bitmap_idx));
630630
if (arena->field_count <= mi_bitmap_index_field(bitmap_idx)) {
631-
_mi_error_message(EINVAL, "trying to free from non-existent arena block: %p, size %zu, memid: 0x%zx\n", p, size, memid);
631+
_mi_error_message(EINVAL, "trying to free from non-existent arena block: %p, size %zu, memid: 0x%zx\n", p, size, (size_t)*(uintptr_t*)&memid);
632632
return;
633633
}
634634

mimalloc/mimalloc-sys/mimalloc/src/prim/unix/prim.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ int _mi_prim_alloc_huge_os_pages(void* hint_addr, size_t size, int numa_node, bo
449449
long err = mi_prim_mbind(*addr, size, MPOL_PREFERRED, &numa_mask, 8*MI_INTPTR_SIZE, 0);
450450
if (err != 0) {
451451
err = errno;
452-
_mi_warning_message("failed to bind huge (1GiB) pages to numa node %d (error: %d (0x%x))\n", numa_node, err, err);
452+
_mi_warning_message("failed to bind huge (1GiB) pages to numa node %d (error: %ld (0x%lx))\n", numa_node, err, err);
453453
}
454454
}
455455
return (*addr != NULL ? 0 : errno);
@@ -491,7 +491,7 @@ size_t _mi_prim_numa_node_count(void) {
491491
unsigned node = 0;
492492
for(node = 0; node < 256; node++) {
493493
// enumerate node entries -- todo: it there a more efficient way to do this? (but ensure there is no allocation)
494-
snprintf(buf, 127, "/sys/devices/system/node/node%u", node + 1);
494+
snprintf(buf, sizeof(buf), "/sys/devices/system/node/node%u", node + 1);
495495
if (mi_prim_access(buf,R_OK) != 0) break;
496496
}
497497
return (node+1);

0 commit comments

Comments
 (0)