This is an automated email from Gerrit.

"Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8181

-- gerrit

commit 7ef45d3104f51c9ad9aafc5a8acb620fc1ac63c4
Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>
Date:   Wed Mar 20 15:16:25 2024 +0300

    target/breakpoints: do not use `*->number` field
    
    Using this field in target-type-independent code is not safe, since
    the initialization is target-type-specific and the field may be
    uninitialized.
    
    Change-Id: I715833a9488311c4858b3d630fbdb2197cc2afc1
    Signed-off-by: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>

diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c
index c39a980570..c8d982e770 100644
--- a/src/target/breakpoints.c
+++ b/src/target/breakpoints.c
@@ -60,7 +60,7 @@ static int breakpoint_add_internal(struct target *target,
                breakpoint = breakpoint->next;
        }
 
-       (*breakpoint_p) = malloc(sizeof(struct breakpoint));
+       (*breakpoint_p) = calloc(sizeof(struct breakpoint));
        (*breakpoint_p)->address = address;
        (*breakpoint_p)->asid = 0;
        (*breakpoint_p)->length = length;
@@ -292,8 +292,8 @@ static int breakpoint_free(struct target *target, struct 
breakpoint *breakpoint_
 
        retval = target_remove_breakpoint(target, breakpoint);
        if (retval != ERROR_OK) {
-               LOG_TARGET_ERROR(target, "could not remove breakpoint #%d on 
this target",
-                                               breakpoint->number);
+               LOG_TARGET_ERROR(target, "could not remove breakpoint, BPID: %" 
PRIu32,
+                               breakpoint->unique_id);
                return retval;
        }
 
@@ -398,8 +398,8 @@ static int watchpoint_free(struct target *target, struct 
watchpoint *watchpoint_
                return ERROR_OK;
        retval = target_remove_watchpoint(target, watchpoint);
        if (retval != ERROR_OK) {
-               LOG_TARGET_ERROR(target, "could not remove watchpoint #%d on 
this target",
-                                                watchpoint->number);
+               LOG_TARGET_ERROR(target, "could not remove watchpoint, WPID: %" 
PRIu32,
+                               watchpoint->unique_id);
                return retval;
        }
 

-- 

Reply via email to