This is an automated email from Gerrit.

"Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/9270

-- gerrit

commit 5cfe46ff2300a59970685c0ad8f9b20c23290173
Author: Tomas Vanek <[email protected]>
Date:   Fri Nov 28 11:53:14 2025 +0100

    target/cortex_a: avoid adding of error return codes
    
    The arithmetic addition of the returned error codes was used
    as a lazy man's logical or.
    
    Handle error passing properly.
    
    Change-Id: I01f012c2f96131a47be9504ac56d28ea28990626
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c
index 3d8603a4ba..d47eb11bdf 100644
--- a/src/target/cortex_a.c
+++ b/src/target/cortex_a.c
@@ -671,18 +671,22 @@ static struct target *get_cortex_a(struct target *target, 
int32_t coreid)
        }
        return target;
 }
+
 static int cortex_a_halt(struct target *target);
 
 static int cortex_a_halt_smp(struct target *target)
 {
-       int retval = 0;
+       int retval = ERROR_OK;
        struct target_list *head;
 
        foreach_smp_target(head, target->smp_targets) {
                struct target *curr = head->target;
                if ((curr != target) && (curr->state != TARGET_HALTED)
-                       && target_was_examined(curr))
-                       retval += cortex_a_halt(curr);
+                               && target_was_examined(curr)) {
+                       int retval1 = cortex_a_halt(curr);
+                       if (retval == ERROR_OK)
+                               retval = retval1;       // save the first error 
and continue loop
+               }
        }
        return retval;
 }
@@ -692,12 +696,12 @@ static int update_halt_gdb(struct target *target)
        struct target *gdb_target = NULL;
        struct target_list *head;
        struct target *curr;
-       int retval = 0;
+       int retval = ERROR_OK;
 
        if (target->gdb_service && target->gdb_service->core[0] == -1) {
                target->gdb_service->target = target;
                target->gdb_service->core[0] = target->coreid;
-               retval += cortex_a_halt_smp(target);
+               retval = cortex_a_halt_smp(target);
        }
 
        if (target->gdb_service)

-- 

Reply via email to