mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
MISRAC2012-Rule-12.1: add suggested parentheses
This commit is contained in:
parent
a1df452e0d
commit
5df9dc7819
4
3rd-party/yxml/yxml.c
vendored
4
3rd-party/yxml/yxml.c
vendored
@ -188,7 +188,7 @@ static inline yxml_ret_t yxml_datacd2(yxml_t *x, unsigned ch) {
|
||||
|
||||
static inline yxml_ret_t yxml_dataattr(yxml_t *x, unsigned ch) {
|
||||
/* Normalize attribute values according to the XML spec section 3.3.3. */
|
||||
yxml_setchar(x->data, (ch == 0x9) || (ch == 0xa) ? 0x20 : ch);
|
||||
yxml_setchar(x->data, ((ch == 0x9) || (ch == 0xa)) ? 0x20 : ch);
|
||||
x->data[1] = 0;
|
||||
return YXML_ATTRVAL;
|
||||
}
|
||||
@ -270,7 +270,7 @@ static inline yxml_ret_t yxml_pistart (yxml_t *x, unsigned ch) { return yxml_pu
|
||||
static inline yxml_ret_t yxml_piname (yxml_t *x, unsigned ch) { return yxml_pushstackc(x, ch); }
|
||||
static inline yxml_ret_t yxml_piabort (yxml_t *x, unsigned ch) { (void) x; (void) ch; yxml_popstack(x); return YXML_OK; }
|
||||
static inline yxml_ret_t yxml_pinameend(yxml_t *x, unsigned ch) { (void) ch;
|
||||
return ((x->pi[0]|32) == 'x') && ((x->pi[1]|32) == 'm') && ((x->pi[2]|32) == 'l') && !x->pi[3] ? YXML_ESYN : YXML_PISTART;
|
||||
return (((x->pi[0]|32) == 'x') && ((x->pi[1]|32) == 'm') && ((x->pi[2]|32) == 'l') && !x->pi[3]) ? YXML_ESYN : YXML_PISTART;
|
||||
}
|
||||
static inline yxml_ret_t yxml_pivalend (yxml_t *x, unsigned ch) { (void) ch; yxml_popstack(x); x->pi = (char *)x->stack; return YXML_PIEND; }
|
||||
|
||||
|
@ -502,7 +502,7 @@ static uint16_t handle_find_by_type_value_request2(att_connection_t * att_connec
|
||||
prev_handle = it.handle;
|
||||
|
||||
// does current attribute match
|
||||
if (it.handle && att_iterator_match_uuid16(&it, attribute_type) && (attribute_len == it.value_len) && memcmp(attribute_value, it.value, it.value_len) == 0){
|
||||
if (it.handle && att_iterator_match_uuid16(&it, attribute_type) && (attribute_len == it.value_len) && (memcmp(attribute_value, it.value, it.value_len) == 0)){
|
||||
log_info("Begin of group, handle 0x%04x", it.handle);
|
||||
little_endian_store_16(response_buffer, offset, it.handle);
|
||||
offset += 2;
|
||||
@ -1224,7 +1224,7 @@ int gatt_server_get_get_handle_range_for_service_with_uuid16(uint16_t uuid16, ui
|
||||
prev_handle = it.handle;
|
||||
|
||||
// check if found
|
||||
if (it.handle && new_service_started && (attribute_len == it.value_len) && memcmp(attribute_value, it.value, it.value_len) == 0){
|
||||
if (it.handle && new_service_started && (attribute_len == it.value_len) && (memcmp(attribute_value, it.value, it.value_len) == 0)){
|
||||
*start_handle = it.handle;
|
||||
in_group = 1;
|
||||
}
|
||||
@ -1308,7 +1308,7 @@ int gatt_server_get_get_handle_range_for_service_with_uuid128(const uint8_t * uu
|
||||
prev_handle = it.handle;
|
||||
|
||||
// check if found
|
||||
if (it.handle && new_service_started && (attribute_len == it.value_len) && memcmp(attribute_value, it.value, it.value_len) == 0){
|
||||
if (it.handle && new_service_started && (attribute_len == it.value_len) && (memcmp(attribute_value, it.value, it.value_len) == 0)){
|
||||
*start_handle = it.handle;
|
||||
in_group = 1;
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ static void characteristic_start_found(gatt_client_t * peripheral, uint16_t star
|
||||
reverse_128(uuid, uuid128);
|
||||
}
|
||||
|
||||
if (peripheral->filter_with_uuid && memcmp(peripheral->uuid128, uuid128, 16) != 0) return;
|
||||
if (peripheral->filter_with_uuid && (memcmp(peripheral->uuid128, uuid128, 16) != 0)) return;
|
||||
|
||||
peripheral->characteristic_properties = properties;
|
||||
peripheral->characteristic_start_handle = start_handle;
|
||||
|
@ -1280,7 +1280,7 @@ static void sm_key_distribution_handle_all_received(sm_connection_t * sm_conn){
|
||||
// skip unused entries
|
||||
if (address_type == BD_ADDR_TYPE_UNKNOWN) continue;
|
||||
log_info("device %u, sm peer addr type %u, peer addres %s", i, address_type, bd_addr_to_str(address));
|
||||
if ((address_type == BD_ADDR_TYPE_LE_PUBLIC) && memcmp(address, setup->sm_peer_address, 6) == 0){
|
||||
if ((address_type == BD_ADDR_TYPE_LE_PUBLIC) && (memcmp(address, setup->sm_peer_address, 6) == 0)){
|
||||
log_info("sm: device found for public address, updating");
|
||||
le_db_index = i;
|
||||
break;
|
||||
@ -1927,7 +1927,7 @@ static void sm_run(void){
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sm_address_resolution_addr_type == addr_type) && memcmp(addr, sm_address_resolution_address, 6) == 0){
|
||||
if ((sm_address_resolution_addr_type == addr_type) && (memcmp(addr, sm_address_resolution_address, 6) == 0)){
|
||||
log_info("LE Device Lookup: found CSRK by { addr_type, address} ");
|
||||
sm_address_resolution_handle_event(ADDRESS_RESOLUTION_SUCEEDED);
|
||||
break;
|
||||
|
@ -360,7 +360,7 @@ int sscanf_bd_addr(const char * addr_string, bd_addr_t addr){
|
||||
}
|
||||
// skip supported separators
|
||||
char next_char = *addr_string;
|
||||
if ((next_char == ':') || (next_char == '-') || next_char == ' ') {
|
||||
if ((next_char == ':') || (next_char == '-') || (next_char == ' ')) {
|
||||
addr_string++;
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ static void avrcp_browsing_parser_process_byte(uint8_t byte, avrcp_browsing_conn
|
||||
}
|
||||
case AVRCP_PARSER_IGNORE_REST_OF_ATTRIBUTE_VALUE:
|
||||
connection->parsed_attribute_value_offset++;
|
||||
if (connection->parsed_attribute_value_offset < big_endian_read_16(connection->parser_attribute_header, 1) + prepended_header_size){
|
||||
if (connection->parsed_attribute_value_offset < (big_endian_read_16(connection->parser_attribute_header, 1) + prepended_header_size)){
|
||||
break;
|
||||
}
|
||||
connection->parser_state = AVRCP_PARSER_GET_ATTRIBUTE_HEADER;
|
||||
|
@ -343,7 +343,7 @@ hfp_connection_t * get_hfp_connection_context_for_bd_addr(bd_addr_t bd_addr, hfp
|
||||
btstack_linked_list_iterator_init(&it, hfp_get_connections());
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it);
|
||||
if (memcmp(hfp_connection->remote_addr, bd_addr, 6) == 0 && (hfp_connection->local_role == hfp_role)) {
|
||||
if ((memcmp(hfp_connection->remote_addr, bd_addr, 6) == 0) && (hfp_connection->local_role == hfp_role)) {
|
||||
return hfp_connection;
|
||||
}
|
||||
}
|
||||
@ -1110,7 +1110,7 @@ void hfp_parse(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree)
|
||||
}
|
||||
|
||||
// TODO: handle space inside word
|
||||
if (byte == ' ' && (hfp_connection->parser_state > HFP_PARSER_CMD_HEADER)) return;
|
||||
if ((byte == ' ') && (hfp_connection->parser_state > HFP_PARSER_CMD_HEADER)) return;
|
||||
|
||||
if ((byte == ',') && hfp_connection->command == HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE){
|
||||
if (hfp_connection->line_size == 0){
|
||||
|
@ -359,8 +359,8 @@ static int sdp_traversal_attributeID_search(uint8_t * element, de_type_t type, d
|
||||
}
|
||||
break;
|
||||
case DE_SIZE_32:
|
||||
if (big_endian_read_16(element, 1) <= context->attributeID
|
||||
&& context->attributeID <= big_endian_read_16(element, 3)) {
|
||||
if ((big_endian_read_16(element, 1) <= context->attributeID)
|
||||
&& (context->attributeID <= big_endian_read_16(element, 3))) {
|
||||
context->result = 1;
|
||||
return 1;
|
||||
}
|
||||
@ -610,7 +610,7 @@ static int sdp_traversal_contains_UUID128(uint8_t * element, de_type_t type, de_
|
||||
uint8_t normalizedUUID[16];
|
||||
if (type == DE_UUID){
|
||||
uint8_t uuidOK = de_get_normalized_uuid(normalizedUUID, element);
|
||||
context->result = uuidOK && memcmp(context->uuid128, normalizedUUID, 16) == 0;
|
||||
context->result = uuidOK && (memcmp(context->uuid128, normalizedUUID, 16) == 0);
|
||||
}
|
||||
if (type == DE_DES){
|
||||
context->result = sdp_record_contains_UUID128(element, context->uuid128);
|
||||
|
@ -151,11 +151,11 @@ extern "C" {
|
||||
#define HCI_CMD_PAYLOAD_SIZE 255
|
||||
|
||||
//
|
||||
#define IS_COMMAND(packet, command) (little_endian_read_16(packet,0) == command.opcode)
|
||||
#define IS_COMMAND(packet, command) ( little_endian_read_16(packet,0) == command.opcode )
|
||||
|
||||
// check if command complete event for given command
|
||||
#define HCI_EVENT_IS_COMMAND_COMPLETE(event,cmd) ( event[0] == HCI_EVENT_COMMAND_COMPLETE && little_endian_read_16(event,3) == cmd.opcode)
|
||||
#define HCI_EVENT_IS_COMMAND_STATUS(event,cmd) ( event[0] == HCI_EVENT_COMMAND_STATUS && little_endian_read_16(event,4) == cmd.opcode)
|
||||
#define HCI_EVENT_IS_COMMAND_COMPLETE(event,cmd) ( (event[0] == HCI_EVENT_COMMAND_COMPLETE) && (little_endian_read_16(event,3) == cmd.opcode) )
|
||||
#define HCI_EVENT_IS_COMMAND_STATUS(event,cmd) ( (event[0] == HCI_EVENT_COMMAND_STATUS) && (little_endian_read_16(event,4) == cmd.opcode) )
|
||||
|
||||
// Code+Len=2, Pkts+Opcode=3; total=5
|
||||
#define OFFSET_OF_DATA_IN_COMMAND_COMPLETE 5
|
||||
|
@ -15,6 +15,9 @@ cstat_file = 'cstat.txt'
|
||||
# project prefix
|
||||
project_prefix = 'c:\\projects\\iar\\btstack\\btstack\\'
|
||||
|
||||
def remove_whitespace(line):
|
||||
return line.replace(' ','')
|
||||
|
||||
def add_parantheses(line, expression):
|
||||
stripped_line = ''
|
||||
positions = []
|
||||
@ -50,6 +53,7 @@ with open(cstat_file, 'rt') as fin:
|
||||
parts = re.match(".*Suggest parentheses.*`(.*)'", msg)
|
||||
total += 1
|
||||
expression = parts.groups()[0]
|
||||
expression = remove_whitespace(expression)
|
||||
# skip some expressions
|
||||
if expression.endswith('=='): continue
|
||||
if expression.endswith('!='): continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user