Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Peter Stuge
Peter Stuge wrote: > The alternative is quite straightforward, so I would > strongly prefer not going there. Allow me to clarify that; The alternative of rewriting to use no double pointers makes the code much more straightforward, so I would strongly prefer not using any double pointers. :) //

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Paul Richards
On 2010/12/11 13:00, Peter Stuge wrote: Afraid not. The alternative is quite straightforward, so I would strongly prefer not going there. Thought as much :-) Well, will leave it up to you guys to decide. I can test any new patches required. Cheers, Paul __

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Peter Stuge
Paul Richards wrote: > Peter, note that the double pointers are in the target list function > implementations (that would be copied), are you ok with this? Afraid not. The alternative is quite straightforward, so I would strongly prefer not going there. Thanks! //Peter

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Paul Richards
On 2010/12/11 8:20, Andreas Fritiofson wrote: 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 b

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Andreas Fritiofson
On Fri, Dec 10, 2010 at 11:39 PM, Peter Stuge 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 be

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Peter Stuge
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

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Andreas Fritiofson
On Fri, Dec 10, 2010 at 4:16 PM, Paul Richards wrote: > On 2010/12/10 18:46, Spencer Oliver wrote: >> >> Not looked into it but why do we not just duplicate the existing >> unregister event/timer functions - or are they broken aswell? >> > > They (the target versions) don't appear to have the same

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Paul Richards
On 2010/12/10 18:46, Spencer Oliver wrote: Not looked into it but why do we not just duplicate the existing unregister event/timer functions - or are they broken aswell? They (the target versions) don't appear to have the same problem. The only difference I can see is that the jtag_unregist

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Paul Richards
On 2010/12/10 17:34, Øyvind Harboe wrote: I think optimizing for testability & readability is the way to go here. Especially considering the evidence that this code doesn't get tested a whole lot I can verify that both solutions work. I'm OK with whichever solution you guys choose since y

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Spencer Oliver
On 10/12/2010 08:34, Øyvind Harboe wrote: On Fri, Dec 10, 2010 at 9:28 AM, Peter Stuge wrote: Øyvind Harboe wrote: Two versions attached. I'll leave it to you to decide which is the best way to implement this I prefer the longer but simpler to read one. Were it mostly a smaller my own proj

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Øyvind Harboe
On Fri, Dec 10, 2010 at 9:28 AM, Peter Stuge wrote: > Øyvind Harboe wrote: >> > Two versions attached. >> >> I'll leave it to you to decide which is the best way to >> implement this > > I prefer the longer but simpler to read one. Were it mostly a smaller > my own project then I'd gone with the s

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-10 Thread Peter Stuge
Øyvind Harboe wrote: > > Two versions attached. > > I'll leave it to you to decide which is the best way to > implement this I prefer the longer but simpler to read one. Were it mostly a smaller my own project then I'd gone with the shorter one. > and to incorporate any feedback. I doubt anyon

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-09 Thread Øyvind Harboe
On Fri, Dec 10, 2010 at 8:27 AM, Peter Stuge wrote: > Øyvind Harboe wrote: >> > double pointers are horrible. >> >> Ah, missed that. Well another patch is gladly accepted, meanwhile >> it no longer crashes. > > Fair. Two versions attached. One which makes the code two lines > longer and avoids dou

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-09 Thread Peter Stuge
Øyvind Harboe wrote: > > double pointers are horrible. > > Ah, missed that. Well another patch is gladly accepted, meanwhile > it no longer crashes. Fair. Two versions attached. One which makes the code two lines longer and avoids double pointers, and a remix which uses only a single double point

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-09 Thread Øyvind Harboe
On Fri, Dec 10, 2010 at 8:05 AM, Peter Stuge wrote: > Øyvind Harboe wrote: >> Merged. > > So I should have complained more loudly. The double pointers are > horrible. Ah, missed that. Well another patch is gladly accepted, meanwhile it no longer crashes. Hopefully the fact that I accepted a patch

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-09 Thread Peter Stuge
Øyvind Harboe wrote: > Merged. So I should have complained more loudly. The double pointers are horrible. //Peter ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-09 Thread Øyvind Harboe
Merged. Thanks! -- Øyvind Harboe Can Zylin Consulting help on your project? US toll free 1-866-980-3434 / International +47 51 63 25 00 http://www.zylin.com/zy1000.html ARM7 ARM9 ARM11 XScale Cortex JTAG debugger and flash programmer ___ Openocd-d

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-08 Thread Paul Richards
I'm attaching the patch proposed in the last mail as I'll be offline shortly. Regards, Paul On 2010/12/08 18:02, Paul Richards wrote: On 2010/12/08 16:27, Peter Stuge wrote: The priv comparison logic is reversed. Sorry, can't believe that snuck in, thanks. The code is horrible. (Certain

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-08 Thread Paul Richards
On 2010/12/08 16:27, Peter Stuge wrote: The priv comparison logic is reversed. Sorry, can't believe that snuck in, thanks. The code is horrible. (Certainly not your fault!) Sorry if that's offensive to the original author. The variable names do not help. Will this work: int jtag_unregister_

Re: [Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-07 Thread Peter Stuge
Paul Richards wrote: > +++ b/src/jtag/core.c > @@ -296,27 +296,25 @@ int jtag_register_event_callback(jtag_event_handler_t > callback, void *priv) > > int jtag_unregister_event_callback(jtag_event_handler_t callback, void *priv) > { > - struct jtag_event_callback **callbacks_p; > - str

[Openocd-development] [PATCH] Fix for segmentation fault from freed memory access in jtag_unregister_event_callback()

2010-12-07 Thread Paul Richards
Fix for issue described in the following mail https://lists.berlios.de/pipermail/openocd-development/2010-December/017479.html From c78f5203622438e73580c327a6e55a0df17b85a8 Mon Sep 17 00:00:00 2001 From: Paul Richards Date: Wed, 8 Dec 2010 15:48:55 +0900 Subject: [PATCH] Fix for segmentation fa