From 8dc629b6e45773b431e4aa374107698fca8ab7e5 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 3 Nov 2025 09:43:05 +0100 Subject: [PATCH] c code updated with discrete type conversions --- src/coparun/coparun.c | 2 +- src/coparun/runmem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coparun/coparun.c b/src/coparun/coparun.c index 919eaa1..9e77fe6 100644 --- a/src/coparun/coparun.c +++ b/src/coparun/coparun.c @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Usage: %s \n", argv[0]); return EXIT_FAILURE; } - FILE *f = fopen(argv[2], "wb"); + f = fopen(argv[2], "wb"); fwrite(executable_memory, 1, (size_t)executable_memory_len, f); fclose(f); } diff --git a/src/coparun/runmem.c b/src/coparun/runmem.c index 90400c7..588bdb5 100644 --- a/src/coparun/runmem.c +++ b/src/coparun/runmem.c @@ -28,9 +28,9 @@ void patch(uint8_t *patch_addr, uint32_t patch_mask, int32_t value) { uint32_t *val_ptr = (uint32_t*)patch_addr; uint32_t original = *val_ptr; - int32_t shift_factor = patch_mask & -patch_mask; + uint32_t shift_factor = patch_mask & -patch_mask; - uint32_t new_value = (original & ~patch_mask) | ((uint32_t)(value * shift_factor) & patch_mask); + uint32_t new_value = (original & ~patch_mask) | (((uint32_t)value * shift_factor) & patch_mask); *val_ptr = new_value; }