On Thu, 2009-06-11 at 08:33 +0200, Øyvind Harboe wrote: > With synchronous and asynchronous execution error handling > becomes a bit trickier... > > I'm thinking that jtag_add_pathmove() and jtag_add_stavemove() > should be split into two: checking args and queing fns. > > Performance sensitive code that *KNOWS* that the arguments > are correct can invoke the queue fn directly. The queue fn can > have assert()'s that are compiled out. > > The argument checking fn can be invoked explicitly without queing > a operation. > > a wrapper fn for the two should be written that does precisely > the same as today, except that jtag_add_statemove() should, > like, jtag_add_pathmove() return void. The programming model > is that everything is queued and then the error is checked > at jtag_add_execute_queue(). Code that needs to know the > error sooner should invoke jtag_execute_queue() "more often" > or use the arg checking fn's directly. > > Patch attached to illustrate what I have in mind.
assert() simply does not seem correct for this kind of check; you are not checking for programming errors. These checks are for potential run-time errors -- particularly now that you have added a Jim command to call this function directly. Your patch still puts the assert back into the path of the normal flow, so this puts us back in the situation of exiting abruptly when the user makes a typo. That should not happen, even with debug builds. Since the assert gets removed with -DNDEBUG, jtag_add_pathmove_nocheck will no longer call to jtag_check_pathmove to validate user-supplied arguments, for either version of the APIs you define. Please do not apply. --Z _______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
