urj_vhdl_set_entity() saved the entity name in the parts part_name even though we don't know at that stage if the idcode matches for this file.
Hunting this bug down, I found too many things are called part, so part of this is to change part->part to part->part_name, ditto for manufaturer to make it easier to find the offender. --- urjtag/include/urjtag/part.h | 4 ++-- urjtag/src/bfin/bfin.c | 2 +- urjtag/src/bsdl/bsdl.c | 5 ++++- urjtag/src/bsdl/bsdl_types.h | 2 ++ urjtag/src/bsdl/vhdl_bison.y | 5 ++--- urjtag/src/part/part.c | 6 +++--- urjtag/src/tap/detect.c | 8 ++++---- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/urjtag/include/urjtag/part.h b/urjtag/include/urjtag/part.h index f0cddbc7..50ce74df 100644 --- a/urjtag/include/urjtag/part.h +++ b/urjtag/include/urjtag/part.h @@ -42,8 +42,8 @@ struct URJ_PART { urj_tap_register_t *id; char *alias; /* djf refdes */ - char manufacturer[URJ_PART_MANUFACTURER_MAXLEN + 1]; - char part[URJ_PART_PART_MAXLEN + 1]; + char manufacturer_name[URJ_PART_MANUFACTURER_MAXLEN + 1]; + char part_name[URJ_PART_PART_MAXLEN + 1]; char stepping[URJ_PART_STEPPING_MAXLEN + 1]; urj_part_signal_t *signals; urj_part_salias_t *saliases; diff --git a/urjtag/src/bfin/bfin.c b/urjtag/src/bfin/bfin.c index dd4bd3b2..d7c9d39d 100644 --- a/urjtag/src/bfin/bfin.c +++ b/urjtag/src/bfin/bfin.c @@ -131,7 +131,7 @@ part_scan_select (urj_chain_t *chain, int n, int scan) if (part->active_instruction == NULL) { urj_log (URJ_LOG_LEVEL_ERROR, - _("%s: unknown instruction '%s'\n"), part->part, scans[scan]); + _("%s: unknown instruction '%s'\n"), part->part_name, scans[scan]); return -1; } diff --git a/urjtag/src/bsdl/bsdl.c b/urjtag/src/bsdl/bsdl.c index afb5d635..d81e969e 100644 --- a/urjtag/src/bsdl/bsdl.c +++ b/urjtag/src/bsdl/bsdl.c @@ -140,10 +140,13 @@ urj_bsdl_read_file (urj_chain_t *chain, const char *BSDL_File_Name, result = urj_bsdl_process_elements (&jtag_ctrl, idcode); - if (result >= 0) + if (result >= 0) { + strncpy(jtag_ctrl.part->part_name, vhdl_parser_priv->entity_name, URJ_PART_PART_MAXLEN); + jtag_ctrl.part->part_name[URJ_PART_PART_MAXLEN] = '\0'; urj_bsdl_msg (proc_mode, _("BSDL file '%s' passed BSDL stage correctly\n"), BSDL_File_Name); + } } else diff --git a/urjtag/src/bsdl/bsdl_types.h b/urjtag/src/bsdl/bsdl_types.h index d19ffd11..efe09579 100644 --- a/urjtag/src/bsdl/bsdl_types.h +++ b/urjtag/src/bsdl/bsdl_types.h @@ -157,10 +157,12 @@ typedef struct jtag_ctrl urj_bsdl_jtag_ctrl_t; /* private data of the VHDL bison parser used to store variables the would end up as globals otherwise */ +#define VHDL_PARSER_ENTITY_NAME_MAXLEN 20 struct vhdl_parser_priv { char Package_File_Name[100]; int Reading_Package; + char entity_name[VHDL_PARSER_ENTITY_NAME_MAXLEN+1]; char *buffer; size_t len_buffer; void *scanner; diff --git a/urjtag/src/bsdl/vhdl_bison.y b/urjtag/src/bsdl/vhdl_bison.y index 4030b3b4..4d057df5 100644 --- a/urjtag/src/bsdl/vhdl_bison.y +++ b/urjtag/src/bsdl/vhdl_bison.y @@ -918,9 +918,8 @@ urj_vhdl_set_entity (urj_vhdl_parser_priv_t *priv, char *entityname) { if (priv->jtag_ctrl->proc_mode & URJ_BSDL_MODE_INSTR_EXEC) { - strncpy (priv->jtag_ctrl->part->part, entityname, - URJ_PART_PART_MAXLEN); - priv->jtag_ctrl->part->part[URJ_PART_PART_MAXLEN] = '\0'; + strncpy (priv->entity_name, entityname, VHDL_PARSER_ENTITY_NAME_MAXLEN); + priv->entity_name[VHDL_PARSER_ENTITY_NAME_MAXLEN] = '\0'; } free (entityname); diff --git a/urjtag/src/part/part.c b/urjtag/src/part/part.c index b7297a05..f5c4dbd0 100644 --- a/urjtag/src/part/part.c +++ b/urjtag/src/part/part.c @@ -52,8 +52,8 @@ urj_part_alloc (const urj_tap_register_t *id) p->alias = NULL; /* djf */ /* @@@@ RFHH check result */ p->id = urj_tap_register_duplicate (id); - p->manufacturer[0] = '\0'; - p->part[0] = '\0'; + p->manufacturer_name[0] = '\0'; + p->part_name[0] = '\0'; p->stepping[0] = '\0'; p->signals = NULL; p->saliases = NULL; @@ -319,7 +319,7 @@ urj_part_print (urj_log_level_t ll, urj_part_t *p) instruction = _("(none)"); if (dr == NULL) dr = _("(none)"); - urj_log (ll, format, p->manufacturer, p->part, p->stepping, instruction, + urj_log (ll, format, p->manufacturer_name, p->part_name, p->stepping, instruction, dr); return URJ_STATUS_OK; diff --git a/urjtag/src/tap/detect.c b/urjtag/src/tap/detect.c index 5c139507..526d2a99 100644 --- a/urjtag/src/tap/detect.c +++ b/urjtag/src/tap/detect.c @@ -419,8 +419,8 @@ urj_tap_detect_parts (urj_chain_t *chain, const char *db_path, int maxirlen) data_path); /* run JTAG declarations */ - strcpy (part->manufacturer, manufacturer); - strcpy (part->part, partname); + strcpy (part->manufacturer_name, manufacturer); + strcpy (part->part_name, partname); strcpy (part->stepping, stepping); if (urj_parse_include (chain, data_path, 1) == URJ_STATUS_FAIL) urj_log_error_describe (URJ_LOG_LEVEL_ERROR); @@ -434,7 +434,7 @@ urj_tap_detect_parts (urj_chain_t *chain, const char *db_path, int maxirlen) "IDCODE"); /* Do part specific initialization. */ - part_init_func = urj_part_find_init (part->part); + part_init_func = urj_part_find_init (part->part_name); if (part_init_func) { part->params = malloc (sizeof (urj_part_params_t)); @@ -496,7 +496,7 @@ urj_tap_manual_add (urj_chain_t *chain, int instr_len) if (part == NULL) return -1; - strncpy (part->part, "unknown", URJ_PART_PART_MAXLEN); + strncpy (part->part_name, "unknown", URJ_PART_PART_MAXLEN); part->instruction_length = instr_len; urj_part_parts_add_part (chain->parts, part); -- 2.21.0 _______________________________________________ UrJTAG-development mailing list UrJTAG-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/urjtag-development