The fix for my bsbit_alloc bug was still wrong

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1560 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent 05c742ca7a
commit 3e0430466d

@ -55,9 +55,11 @@ struct urj_bsbit
* @param name associated signal name
* @param type URJ_BSBIT_{INPUT|OUTPUT|BIDIR|CONTROL|INTERNAL}
* @param safe default (safe) value (0|1)
*
* @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error
*/
urj_bsbit_t *urj_part_bsbit_alloc (urj_part_t *part, int bit,
const char *name, int type, int safe);
int urj_part_bsbit_alloc (urj_part_t *part, int bit, const char *name,
int type, int safe);
/**
* Define new BSR (Boundary Scan Register) bit for signal <code>name</code>.
* Additionally, define control bit.
@ -70,11 +72,12 @@ urj_bsbit_t *urj_part_bsbit_alloc (urj_part_t *part, int bit,
* @param ctrl_num control bit number
* @param ctrl_val control value
* @param ctrl_state control state; valid statis is only URJ_BSBIT_STATE_Z
*
* @return URJ_STATUS_OK on success; URJ_STATUS_FAIL on error
*/
urj_bsbit_t *urj_part_bsbit_alloc_control (urj_part_t *part, int bit,
const char *name, int type, int safe,
int ctrl_num, int ctrl_val,
int ctrl_state);
int urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
int type, int safe, int ctrl_num,
int ctrl_val, int ctrl_state);
void urj_part_bsbit_free (urj_bsbit_t *b);

@ -138,9 +138,8 @@ cmd_bit_run (urj_chain_t *chain, char *params[])
/* test for control bit */
if (urj_cmd_params (params) == 5) {
part->bsbits[bit] = urj_part_bsbit_alloc (part, bit, params[4], type,
safe);
if (part->bsbits[bit] == NULL)
if (urj_part_bsbit_alloc (part, bit, params[4], type,
safe) != URJ_STATUS_OK)
{
printf ("%s for command '%s'\n", urj_error_describe(), command);
urj_error_get_reset();
@ -173,11 +172,9 @@ cmd_bit_run (urj_chain_t *chain, char *params[])
control_state = URJ_BSBIT_STATE_Z;
part->bsbits[bit] = urj_part_bsbit_alloc_control (part, bit, params[4],
type, safe, control,
control_value,
control_state);
if (part->bsbits[bit] == NULL)
if (urj_part_bsbit_alloc_control (part, bit, params[4], type, safe,
control, control_value,
control_state) != URJ_STATUS_OK)
{
printf ("%s for command '%s'\n", urj_error_describe(), command);
urj_error_get_reset();

@ -34,7 +34,7 @@
#include <urjtag/bssignal.h>
#include <urjtag/bsbit.h>
urj_bsbit_t *
int
urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
int type, int safe,
int ctrl_num, int ctrl_val, int ctrl_state)
@ -48,18 +48,18 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
{
urj_error_set(URJ_ERROR_NOTFOUND,
_("missing Boundary Scan Register (BSR)"));
return NULL;
return URJ_STATUS_FAIL;
}
if (bit >= bsr->in->len)
{
urj_error_set(URJ_ERROR_INVALID, _("invalid boundary bit number"));
return NULL;
return URJ_STATUS_FAIL;
}
if (part->bsbits[bit] != NULL)
{
urj_error_set(URJ_ERROR_ALREADY, _("duplicate bit declaration"));
return NULL;
return URJ_STATUS_FAIL;
}
signal = urj_part_find_signal (part, name);
@ -70,7 +70,7 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
if (!b)
{
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc fails");
return NULL;
return URJ_STATUS_FAIL;
}
b->name = strdup (name);
@ -78,7 +78,7 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
{
free (b);
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "strdup fails");
return NULL;
return URJ_STATUS_FAIL;
}
b->bit = bit;
@ -87,6 +87,8 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
b->safe = safe;
b->control = -1;
part->bsbits[bit] = b;
if (signal != NULL)
{
switch (type)
@ -109,25 +111,22 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
if (ctrl_num >= bsr->in->len)
{
urj_error_set(URJ_ERROR_INVALID, _("invalid control bit number\n"));
return NULL;
return URJ_STATUS_FAIL;
}
b->control = ctrl_num;
b->control_value = ctrl_val;
b->control_state = URJ_BSBIT_STATE_Z;
}
return b;
return URJ_STATUS_OK;
}
urj_bsbit_t *
int
urj_part_bsbit_alloc (urj_part_t *part, int bit, const char *name, int type,
int safe)
{
urj_bsbit_t *b;
b = urj_part_bsbit_alloc_control (part, bit, name, type, safe, -1, -1, -1);
return b;
return urj_part_bsbit_alloc_control (part, bit, name, type, safe,
-1, -1, -1);
}
void

Loading…
Cancel
Save