This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8974

-- gerrit

commit 13cf15ffdc6b9fd5ecd52e7db3603f17f0b62dd3
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sun Jun 22 11:03:41 2025 +0200

    jtag/drivers: dmem: fix build on Linux 32 bits
    
    On 32 bits machine both 'uintptr_t' and pointers are 32 bit.
    The cast
    (volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr)
    fails with error
            error: cast to pointer from integer of different size
            [-Werror=int-to-pointer-cast]
    in lines 100 and 109 because:
    - 'addr' is a 'uint64_t';
    - adding 'uintptr_t' and 'uint64_t' returns a 64 bit value;
    - cast the 64 bit to 'uint32_t *' is an error.
    
    In the code the value passed to 'addr' is always 32 bit wide, so
    there is no need to pass it as 'uint64_t'.
    
    Change the type of 'addr' to 'uint32_t'.
    Fix also some format string to fit both 32 and 64 bits machines.
    
    Change-Id: I90ff7cd3731cb24a0fc91fe7b69c532b5c698ba0
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/jtag/drivers/dmem.c b/src/jtag/drivers/dmem.c
index e50e84aeeb..b5c6a794fa 100644
--- a/src/jtag/drivers/dmem.c
+++ b/src/jtag/drivers/dmem.c
@@ -93,14 +93,14 @@ static bool dmem_is_emulated_ap(struct adiv5_ap *ap, 
unsigned int *idx)
        return false;
 }
 
-static void dmem_emu_set_ap_reg(uint64_t addr, uint32_t val)
+static void dmem_emu_set_ap_reg(uint32_t addr, uint32_t val)
 {
        addr &= ~ARM_APB_PADDR31;
 
        *(volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr) = val;
 }
 
-static uint32_t dmem_emu_get_ap_reg(uint64_t addr)
+static uint32_t dmem_emu_get_ap_reg(uint32_t addr)
 {
        uint32_t val;
 
@@ -519,7 +519,7 @@ static int dmem_dap_init(void)
                                                 MAP_SHARED, dmem_fd,
                                                 dmem_mapped_start);
        if (dmem_map_base == MAP_FAILED) {
-               LOG_ERROR("Mapping address 0x%lx for 0x%lx bytes failed!",
+               LOG_ERROR("Mapping address 0x%zx for 0x%zx bytes failed!",
                        dmem_mapped_start, dmem_mapped_size);
                goto error_fail;
        }
@@ -543,7 +543,7 @@ static int dmem_dap_init(void)
                                                                           
MAP_SHARED, dmem_fd,
                                                                           
dmem_mapped_start);
                if (dmem_emu_map_base == MAP_FAILED) {
-                       LOG_ERROR("Mapping EMU address 0x%lx for 0x%lx bytes 
failed!",
+                       LOG_ERROR("Mapping EMU address 0x%" PRIx64 " for 0x%" 
PRIx64 " bytes failed!",
                                          dmem_emu_base_address, dmem_emu_size);
                        goto error_fail;
                }

-- 

Reply via email to