From 70aa54c17bf93b7828c744f06234b86c97c97bb0 Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Fri, 8 May 2009 09:50:00 +0000 Subject: [PATCH] Replace occurrence of urj_cmd_run() in svf.c with an API call urj_part_instruction_define() git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1580 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/src/svf/svf.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/urjtag/src/svf/svf.c b/urjtag/src/svf/svf.c index 634a4d0d..d25e5841 100644 --- a/urjtag/src/svf/svf.c +++ b/urjtag/src/svf/svf.c @@ -1182,31 +1182,32 @@ urj_svf_run (urj_chain_t *chain, FILE *SVF_FILE, int stop_on_mismatch, /* setup instruction SIR if not already existing */ if (!(priv.ir = urj_part_find_instruction (priv.part, "SIR"))) { - char *instruction_cmd[] = { "instruction", - "SIR", - "", - "SDR", - NULL - }; - char *instruction_string; - int len, result; + int len; len = priv.part->instruction_length; if (len > 0) { - if ((instruction_string = calloc (len + 1, sizeof (char))) != NULL) + char *instruction_string; + urj_part_instruction_t *sir; + + if ((instruction_string = calloc (len + 1, sizeof (char))) == NULL) { - memset (instruction_string, '1', len); - instruction_string[len] = '\0'; - instruction_cmd[2] = instruction_string; + urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "calloc(%zd,%zd) fails", + (size_t)(len + 1), sizeof (char)); + return 0; + } - result = urj_cmd_run (chain, instruction_cmd); + memset (instruction_string, '1', len); + instruction_string[len] = '\0'; - free (instruction_string); + sir = urj_part_instruction_define (priv.part, "SIR", + instruction_string, "SDR"); - if (result < 1) - return 0; - } + free (instruction_string); + + if (sir == NULL) + // retain error state + return 0; } if (!(priv.ir = urj_part_find_instruction (priv.part, "SIR")))