Skip to content

Commit 160f7b3

Browse files
committed
target: remove events that are set to empty string
Current code allows replacing the body of an existing event, but it doesn't provides a way to remove it. Replacing the event with an empty string makes the event still present and visible through $target_name eventlist The presence of empty events makes more complex checking for the event not set or set to empty. Remove the event when set to empty string. While there, add 'Jim_Length' to the list of allowed CamelCase symbols, avoiding the associated checkpatch error. Change-Id: I1ec2e1a71d298a0eba0b6863902645bcc6c4cb09 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8814 Tested-by: jenkins
1 parent c023534 commit 160f7b3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/target/target.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4968,6 +4968,17 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
49684968
LOG_INFO("DEPRECATED target event %s; use TPIU events {pre,post}-{enable,disable}", n->name);
49694969
/* END_DEPRECATED_TPIU */
49704970

4971+
jim_getopt_obj(goi, &o);
4972+
if (Jim_Length(o) == 0) {
4973+
/* empty action, drop existing one */
4974+
if (teap) {
4975+
list_del(&teap->list);
4976+
Jim_DecrRefCount(teap->interp, teap->body);
4977+
free(teap);
4978+
}
4979+
break;
4980+
}
4981+
49714982
bool replace = true;
49724983
if (!teap) {
49734984
/* create new */
@@ -4976,7 +4987,6 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
49764987
}
49774988
teap->event = n->value;
49784989
teap->interp = goi->interp;
4979-
jim_getopt_obj(goi, &o);
49804990
if (teap->body)
49814991
Jim_DecrRefCount(teap->interp, teap->body);
49824992
teap->body = Jim_DuplicateObj(goi->interp, o);

tools/scripts/camelcase.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Jim_GetWide
122122
Jim_IncrRefCount
123123
Jim_InitStaticExtensions
124124
Jim_Interp
125+
Jim_Length
125126
Jim_ListAppendElement
126127
Jim_ListGetIndex
127128
Jim_ListLength

0 commit comments

Comments
 (0)