This is an automated email from Gerrit.

"Mark O'Donovan <[email protected]>" just uploaded a new patch set to Gerrit, 
which you can find at https://review.openocd.org/c/openocd/+/9497

-- gerrit

commit a074306a189b30c364b414b6d5f8ec7d74ad440a
Author: Mark O'Donovan <[email protected]>
Date:   Mon Mar 9 21:48:16 2026 +0000

    flash/nor/str7x: fix undefined behaviour
    
    Shifting 32 bit signed variables by 31 bits is undefined behaviour
    
    Change-Id: Iec61a98eecd6657ff6ba1dcad6fff76052c917e3
    Signed-off-by: Mark O'Donovan <[email protected]>

diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index 0177095cb9..e84721333b 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -736,7 +736,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
        target_read_u32(target, str7x_get_flash_adr(bank, FLASH_NVAPR1), &reg);
        protection_regs = ~(reg >> 16);
 
-       while (((protection_regs) != 0) && (protection_level < 16)) {
+       while ((protection_regs != 0) && (protection_level < 16)) {
                protection_regs >>= 1;
                protection_level++;
        }
@@ -753,7 +753,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command)
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), 
flash_cmd);
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), 
0x4010DFBC);
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_DR0),
-                               ~(1 << (15 + protection_level)));
+                               ~(1U << (15 + protection_level)));
                flash_cmd = FLASH_SPR | FLASH_WMS;
                target_write_u32(target, str7x_get_flash_adr(bank, FLASH_CR0), 
flash_cmd);
        }

-- 

Reply via email to