]> git.sur5r.net Git - openocd/commitdiff
Simplify jtag_tap_by_jim_object:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 02:23:35 +0000 (02:23 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 02:23:35 +0000 (02:23 +0000)
- 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

src/jtag/jtag.c

index 6e2f63d21425841b53d384c4cc8906a567329fde..336b74f9cbdd099ebd66dfe86f1fb4176bb7fe25 100644 (file)
@@ -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;
 }