summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-09 02:23:35 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-09 02:23:35 +0000
commit009034f56cb87065453363ad674bd94f98c3ed50 (patch)
tree9580b80a2d9e68573289e7bfc7e1a475afb438be
parent9f185eef7d69e3c9d4390f5f7dd78a7644b01c80 (diff)
downloadopenocd_libswd-009034f56cb87065453363ad674bd94f98c3ed50.tar.gz
openocd_libswd-009034f56cb87065453363ad674bd94f98c3ed50.tar.bz2
openocd_libswd-009034f56cb87065453363ad674bd94f98c3ed50.tar.xz
openocd_libswd-009034f56cb87065453363ad674bd94f98c3ed50.zip
Simplify jtag_tap_by_jim_object:
- Merge declarations of temporary variables with first use. - Restructure logic to simplify conditional logic. git-svn-id: svn://svn.berlios.de/openocd/trunk@2142 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/jtag/jtag.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 6e2f63d2..336b74f9 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -299,21 +299,14 @@ jtag_tap_t *jtag_tap_by_string(const char *s)
return jtag_tap_by_abs_position(n);
}
-jtag_tap_t * jtag_tap_by_jim_obj( Jim_Interp *interp, Jim_Obj *o )
+jtag_tap_t *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
{
- jtag_tap_t *t;
- const char *cp;
-
- cp = Jim_GetString( o, NULL );
- if(cp == NULL){
+ const char *cp = Jim_GetString(o, NULL);
+ jtag_tap_t *t = cp ? jtag_tap_by_string(cp) : NULL;
+ if (NULL == cp)
cp = "(unknown)";
- t = NULL;
- } else {
- t = jtag_tap_by_string( cp );
- }
- if( t == NULL ){
- Jim_SetResult_sprintf(interp,"Tap: %s is unknown", cp );
- }
+ if (NULL == t)
+ Jim_SetResult_sprintf(interp, "Tap '%s' could not be found", cp);
return t;
}