]> git.sur5r.net Git - openocd/commitdiff
jtag: avoid using interp global variable
authorZachary T Welch <zw@superlucidity.net>
Mon, 30 Nov 2009 02:08:13 +0000 (18:08 -0800)
committerZachary T Welch <zw@superlucidity.net>
Tue, 1 Dec 2009 00:29:34 +0000 (16:29 -0800)
Adds 'interp' field to jtag_tap_event_action structure to avoid
using the global variable of same name.

src/jtag/jtag.h
src/jtag/tcl.c

index d4fafa3bde1df95bc30582a32b4e8fee10fa4511..ee967752377ed4fe0e618b593b4b9f27873df882 100644 (file)
@@ -209,9 +209,14 @@ enum jtag_event {
 
 struct jtag_tap_event_action
 {
-       enum jtag_event         event;
-       Jim_Obj*                 body;
-       struct jtag_tap_event_action* next;
+       /// The event for which this action will be triggered.
+       enum jtag_event event;
+       /// The interpreter to use for evaluating the @c body.
+       Jim_Interp *interp;
+       /// Contains a script to 'eval' when the @c event is triggered.
+       Jim_Obj *body;
+       // next action in linked list
+       struct jtag_tap_event_action *next;
 };
 
 /**
index 7ec7fa40980fb711b9e408e18508ac9700d64b57..68bb21e40fdfcd41365c74d891b2b48603a05c29 100644 (file)
@@ -341,8 +341,9 @@ static int jtag_tap_configure_event(Jim_GetOptInfo *goi, struct jtag_tap * tap)
                if (!found)
                        jteap = calloc(1, sizeof(*jteap));
                else if (NULL != jteap->body)
-                       Jim_DecrRefCount(interp, jteap->body);
+                       Jim_DecrRefCount(goi->interp, jteap->body);
 
+               jteap->interp = goi->interp;
                jteap->event = n->value;
 
                Jim_Obj *o;
@@ -359,6 +360,7 @@ static int jtag_tap_configure_event(Jim_GetOptInfo *goi, struct jtag_tap * tap)
        }
        else if (found)
        {
+               jteap->interp = goi->interp;
                Jim_SetResult(goi->interp,
                        Jim_DuplicateObj(goi->interp, jteap->body));
        }
@@ -616,9 +618,9 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
                                tap->dotted_name, e, nvp->name,
                                Jim_GetString(jteap->body, NULL));
 
-               if (Jim_EvalObj(interp, jteap->body) != JIM_OK)
+               if (Jim_EvalObj(jteap->interp, jteap->body) != JIM_OK)
                {
-                       Jim_PrintErrorMessage(interp);
+                       Jim_PrintErrorMessage(jteap->interp);
                        continue;
                }