Skip to content

Commit

Permalink
helper/jim-nvp.h: Rework 'isconfigure' variable
Browse files Browse the repository at this point in the history
Change the variable name to 'is_configure' to be compatible with the
coding style and use 'bool' as data type.

Change-Id: I8609f9807c8bd14eaf6c93acf63fd51b55c9bbbb
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/8573
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
  • Loading branch information
zapb-0 authored and borneoa committed Nov 23, 2024
1 parent 61fbcbe commit 8c739a4
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/helper/jim-nvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef OPENOCD_HELPER_JIM_NVP_H
#define OPENOCD_HELPER_JIM_NVP_H

#include <stdbool.h>
#include <jim.h>

/** Name Value Pairs, aka: NVP
Expand Down Expand Up @@ -136,7 +137,7 @@ struct jim_getopt_info {
Jim_Interp *interp;
int argc;
Jim_Obj *const *argv;
int isconfigure; /* non-zero if configure */
bool is_configure;
};

/** GetOpt - how to.
Expand Down
2 changes: 1 addition & 1 deletion src/rtos/rtos.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int rtos_create(struct jim_getopt_info *goi, struct target *target)
Jim_Obj *res;
int e;

if (!goi->isconfigure && goi->argc != 0) {
if (!goi->is_configure && goi->argc != 0) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
return JIM_ERR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/target/aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -2940,7 +2940,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *

switch (n->value) {
case CFG_CTI: {
if (goi->isconfigure) {
if (goi->is_configure) {
Jim_Obj *o_cti;
struct arm_cti *cti;
e = jim_getopt_obj(goi, &o_cti);
Expand Down
6 changes: 3 additions & 3 deletions src/target/arm_adi_v5.c
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ static int adiv5_jim_spot_configure(struct jim_getopt_info *goi,

switch (n->value) {
case CFG_DAP:
if (goi->isconfigure) {
if (goi->is_configure) {
Jim_Obj *o_t;
struct adiv5_dap *dap;
e = jim_getopt_obj(goi, &o_t);
Expand Down Expand Up @@ -2388,7 +2388,7 @@ static int adiv5_jim_spot_configure(struct jim_getopt_info *goi,
break;

case CFG_AP_NUM:
if (goi->isconfigure) {
if (goi->is_configure) {
/* jim_wide is a signed 64 bits int, ap_num is unsigned with max 52 bits */
jim_wide ap_num;
e = jim_getopt_wide(goi, &ap_num);
Expand All @@ -2415,7 +2415,7 @@ static int adiv5_jim_spot_configure(struct jim_getopt_info *goi,
LOG_WARNING("DEPRECATED! use \'-baseaddr' not \'-ctibase\'");
/* fall through */
case CFG_BASEADDR:
if (goi->isconfigure) {
if (goi->is_configure) {
jim_wide base;
e = jim_getopt_wide(goi, &base);
if (e != JIM_OK)
Expand Down
2 changes: 1 addition & 1 deletion src/target/arm_cti.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static int cti_create(struct jim_getopt_info *goi)
adiv5_mem_ap_spot_init(&cti->spot);

/* Do the rest as "configure" options */
goi->isconfigure = 1;
goi->is_configure = true;
e = cti_configure(goi, cti);
if (e != JIM_OK) {
free(cti);
Expand Down
22 changes: 11 additions & 11 deletions src/target/arm_tpiu_swo.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
{
assert(obj);

if (goi->isconfigure && obj->enabled) {
if (goi->is_configure && obj->enabled) {
Jim_SetResultFormatted(goi->interp, "Cannot configure TPIU/SWO; %s is enabled!", obj->name);
return JIM_ERR;
}
Expand All @@ -382,7 +382,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s

switch (n->value) {
case CFG_PORT_WIDTH:
if (goi->isconfigure) {
if (goi->is_configure) {
jim_wide port_width;
e = jim_getopt_wide(goi, &port_width);
if (e != JIM_OK)
Expand All @@ -399,7 +399,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_PROTOCOL:
if (goi->isconfigure) {
if (goi->is_configure) {
struct jim_nvp *p;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_protocol_opts, &p);
if (e != JIM_OK)
Expand All @@ -418,7 +418,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_FORMATTER:
if (goi->isconfigure) {
if (goi->is_configure) {
struct jim_nvp *p;
e = jim_getopt_nvp(goi, nvp_arm_tpiu_swo_bool_opts, &p);
if (e != JIM_OK)
Expand All @@ -437,7 +437,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_TRACECLKIN:
if (goi->isconfigure) {
if (goi->is_configure) {
jim_wide clk;
e = jim_getopt_wide(goi, &clk);
if (e != JIM_OK)
Expand All @@ -450,7 +450,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_BITRATE:
if (goi->isconfigure) {
if (goi->is_configure) {
jim_wide clk;
e = jim_getopt_wide(goi, &clk);
if (e != JIM_OK)
Expand All @@ -463,7 +463,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_OUTFILE:
if (goi->isconfigure) {
if (goi->is_configure) {
const char *s;
e = jim_getopt_string(goi, &s, NULL);
if (e != JIM_OK)
Expand Down Expand Up @@ -491,7 +491,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
}
break;
case CFG_EVENT:
if (goi->isconfigure) {
if (goi->is_configure) {
if (goi->argc < 2) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
return JIM_ERR;
Expand Down Expand Up @@ -521,7 +521,7 @@ static int arm_tpiu_swo_configure(struct jim_getopt_info *goi, struct arm_tpiu_s
ea = ea->next;
}

if (goi->isconfigure) {
if (goi->is_configure) {
if (!ea) {
ea = calloc(1, sizeof(*ea));
if (!ea) {
Expand Down Expand Up @@ -560,7 +560,7 @@ static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * co
struct jim_getopt_info goi;

jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
goi.isconfigure = !strcmp(c->name, "configure");
goi.is_configure = !strcmp(c->name, "configure");
if (goi.argc < 1) {
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
"missing: -option ...");
Expand Down Expand Up @@ -977,7 +977,7 @@ static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const
}

/* Do the rest as "configure" options */
goi.isconfigure = 1;
goi.is_configure = true;
int e = arm_tpiu_swo_configure(&goi, obj);
if (e != JIM_OK)
goto err_exit;
Expand Down
30 changes: 15 additions & 15 deletions src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -4937,7 +4937,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
switch (n->value) {
case TCFG_TYPE:
/* not settable */
if (goi->isconfigure) {
if (goi->is_configure) {
Jim_SetResultFormatted(goi->interp,
"not settable: %s", n->name);
return JIM_ERR;
Expand Down Expand Up @@ -4966,7 +4966,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
return e;
}

if (goi->isconfigure) {
if (goi->is_configure) {
if (goi->argc != 1) {
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
return JIM_ERR;
Expand All @@ -4989,7 +4989,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
teap = teap->next;
}

if (goi->isconfigure) {
if (goi->is_configure) {
/* START_DEPRECATED_TPIU */
if (n->value == TARGET_EVENT_TRACE_CONFIG)
LOG_INFO("DEPRECATED target event %s; use TPIU events {pre,post}-{enable,disable}", n->name);
Expand Down Expand Up @@ -5037,7 +5037,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_WORK_AREA_VIRT:
if (goi->isconfigure) {
if (goi->is_configure) {
target_free_all_working_areas(target);
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
Expand All @@ -5053,7 +5053,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_WORK_AREA_PHYS:
if (goi->isconfigure) {
if (goi->is_configure) {
target_free_all_working_areas(target);
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
Expand All @@ -5069,7 +5069,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_WORK_AREA_SIZE:
if (goi->isconfigure) {
if (goi->is_configure) {
target_free_all_working_areas(target);
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
Expand All @@ -5084,7 +5084,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_WORK_AREA_BACKUP:
if (goi->isconfigure) {
if (goi->is_configure) {
target_free_all_working_areas(target);
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
Expand All @@ -5101,7 +5101,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)


case TCFG_ENDIAN:
if (goi->isconfigure) {
if (goi->is_configure) {
e = jim_getopt_nvp(goi, nvp_target_endian, &n);
if (e != JIM_OK) {
jim_getopt_nvp_unknown(goi, nvp_target_endian, 1);
Expand All @@ -5122,7 +5122,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_COREID:
if (goi->isconfigure) {
if (goi->is_configure) {
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
return e;
Expand All @@ -5136,7 +5136,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_CHAIN_POSITION:
if (goi->isconfigure) {
if (goi->is_configure) {
Jim_Obj *o_t;
struct jtag_tap *tap;

Expand All @@ -5163,7 +5163,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
/* loop for more e*/
break;
case TCFG_DBGBASE:
if (goi->isconfigure) {
if (goi->is_configure) {
e = jim_getopt_wide(goi, &w);
if (e != JIM_OK)
return e;
Expand Down Expand Up @@ -5193,7 +5193,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_GDB_PORT:
if (goi->isconfigure) {
if (goi->is_configure) {
struct command_context *cmd_ctx = current_command_context(goi->interp);
if (cmd_ctx->mode != COMMAND_CONFIG) {
Jim_SetResultString(goi->interp, "-gdb-port must be configured before 'init'", -1);
Expand All @@ -5215,7 +5215,7 @@ static int target_configure(struct jim_getopt_info *goi, struct target *target)
break;

case TCFG_GDB_MAX_CONNECTIONS:
if (goi->isconfigure) {
if (goi->is_configure) {
struct command_context *cmd_ctx = current_command_context(goi->interp);
if (cmd_ctx->mode != COMMAND_CONFIG) {
Jim_SetResultString(goi->interp, "-gdb-max-connections must be configured before 'init'", -1);
Expand Down Expand Up @@ -5246,7 +5246,7 @@ static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *a
struct jim_getopt_info goi;

jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
goi.isconfigure = !strcmp(c->name, "configure");
goi.is_configure = !strcmp(c->name, "configure");
if (goi.argc < 1) {
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
"missing: -option ...");
Expand Down Expand Up @@ -5823,7 +5823,7 @@ static int target_create(struct jim_getopt_info *goi)
target->gdb_max_connections = 1;

/* Do the rest as "configure" options */
goi->isconfigure = 1;
goi->is_configure = true;
e = target_configure(goi, target);

if (e == JIM_OK) {
Expand Down

0 comments on commit 8c739a4

Please sign in to comment.