On Fri, Dec 10, 2010 at 11:39 PM, Peter Stuge <pe...@stuge.se> wrote:
> Andreas Fritiofson wrote:
>> > Now there's 3 versions to choose from :-)
>>
>> It's not too late. The target versions seems nice and readable. And
>> correct, as far as I can see this late hour. I think the jtag version
>> should follow the behavior of these and only remove the first matching
>> handler. That would be the correct thing to do, if there was a point
>> in having the same handler registered more than once.
>
> Really? How are the callbacks being used?

I don't know. But, generally, if I _can_ register the same handler
twice, I'd expect each registration to require a separate unregister
call. The actual call sites would have to be inspected before changing
this behavior, of course. There shouldn't be many of them, since the
bug has gone unnoticed for so long.

>> The only issue I have with copying the target version is that having
>> the same code duplicated in three places probably warrants refactoring
>> it into a helper function instead.
>
> Which is difficult for something simple as a linked list, unless the
> list entries are identical, and of the same type. Are they?

Two of them differ only in the callback signature, the third is very different.

There are several imaginable solutions. You could have the list
functions operate on a generic next pointer, included as the first
element of all specialized list types. Or the actual data could be
stored outside the list structure, with just a void pointer in it.
Both require some nasty casts. Neither is likely to be more clear and
concise than the duplicated code. Maybe if it was used in _ten_
places...

/Andreas
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to