python748 / btstack

Automatically exported from code.google.com/p/btstack
0 stars 0 forks source link

Patch for /trunk/src/l2cap_signaling.c #442

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
API, there is a bug in uint16_t 
l2cap_le_create_connection_parameter_update_request() with usage of the 
Conditional operator '?' in C programming in line number 156: 
int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;
This statement is applicable only if 
Identifier = (test expression)? Expression1: Expression2 ;

test expression should not be an function, it's either arithmetic or logical 
expression between the Variables.

Original issue reported on code.google.com by svrajas...@gmail.com on 11 Feb 2015 at 12:15

Attachments:

GoogleCodeExporter commented 8 years ago
Hi

Which C reference do you use? I don't see why using a function inside the test 
expression is problematic. (closing it for now)

Original comment by matthias.ringwald@gmail.com on 17 Feb 2015 at 9:37

GoogleCodeExporter commented 8 years ago
int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;
please confirm, can we keep the above C programming code as equivalent to below 
mentioned C programming code. 
int pb;
pb = hci_non_flushable_packet_boundary_flag_supported();
if(pb)
return 0x00;
else
return 0x02;

if so which version of the code is optimal(either efficient or optimized)

Original comment by svrajas...@gmail.com on 18 Feb 2015 at 2:35

GoogleCodeExporter commented 8 years ago
I tested the code : 
int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;
works fine with gcc compiler,but still would like to know the comment#2.

Original comment by svrajas...@gmail.com on 18 Feb 2015 at 2:38