Re: [Openocd-development] [PATCH] transport selection fix

2011-06-24 Thread Jie Zhang
On Sat, Jun 18, 2011 at 4:36 AM, Tomek CEDRO  wrote:
> On Thu, Jun 16, 2011 at 9:42 PM, Andreas Fritiofson
>  wrote:
>> a ? : b is equivalent to a ? a : b, unless evaluating a has side-effects or
>> if a is volatile, since it's only evaluated once in the former case and
>> twice in the latter.
>
> Nice to know, thanks! Is that true for all compilers?
>
It's a C language extension provided by GCC. I don't think all
compilers support this.


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


Re: [Openocd-development] [PATCH] transport selection fix

2011-06-18 Thread Tomek CEDRO
On Thu, Jun 16, 2011 at 9:42 PM, Andreas Fritiofson
 wrote:
> a ? : b is equivalent to a ? a : b, unless evaluating a has side-effects or
> if a is volatile, since it's only evaluated once in the former case and
> twice in the latter.

Nice to know, thanks! Is that true for all compilers?

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] transport selection fix

2011-06-16 Thread Andreas Fritiofson
On Thu, Jun 16, 2011 at 8:02 PM, Tomek CEDRO  wrote:

> On Thu, Jun 16, 2011 at 5:50 PM, Øyvind Harboe 
> wrote:
> > I take it is just a bugfix?
>
> Yes - it changes:
>
> retval = allow_transports(CMD_CTX, jtag_interface->transports ? :
> jtag_only);
>
> into:
>
> retval = allow_transports(CMD_CTX, jtag_interface->transports ?
> jtag_interface->transports : jtag_only);
>
> Which was obvious mistake or cautious precaution :-) :-)


Not true!

Your patch doesn't fix a bug, because there is none.

a ? : b is equivalent to a ? a : b, unless evaluating a has side-effects or
if a is volatile, since it's only evaluated once in the former case and
twice in the latter.

I don't think jtag_interface->transports is neither volatile nor a macro
with side-effects. So, in the name of portability (?: is a GCC extension
[1]) and clarity, I'd say this patch is valid, but not for the reasons given
in the patch comment.

/Andreas

[1] http://gcc.gnu.org/onlinedocs/gcc/Conditionals.html
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] transport selection fix

2011-06-16 Thread Øyvind Harboe
Merged.

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] transport selection fix

2011-06-16 Thread Tomek CEDRO
On Thu, Jun 16, 2011 at 5:50 PM, Øyvind Harboe  wrote:
> I take it is just a bugfix?

Yes - it changes:

retval = allow_transports(CMD_CTX, jtag_interface->transports ? : jtag_only);

into:

retval = allow_transports(CMD_CTX, jtag_interface->transports ?
jtag_interface->transports : jtag_only);

Which was obvious mistake or cautious precaution :-) :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] transport selection fix

2011-06-16 Thread Øyvind Harboe
Is this patch ready to go into the master branch *before* any
of the other swd work?

I take it is just a bugfix?

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


[Openocd-development] [PATCH] transport selection fix

2011-06-16 Thread Tomek CEDRO
This patch fixes transport selection mechanism - if transport is
defined it will be selected. Before 'jtag' was always selected no
matter what transport in fact was supposed to be used.

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info


0004-ADAPTER-Fixed-transport-selection-mechanism-to-suppo.patch
Description: Binary data
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development