Bugfix/clang tidy applied 2022 (#232)
* clang-tidy applied fixes to src folder * clang-tidy applied fixes to apps folder Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -307,8 +307,9 @@ int dl_ip_recv(
|
||||
}
|
||||
|
||||
/* the signature of a BACnet/IP packet */
|
||||
if (data->buff[0] != BVLL_TYPE_BACNET_IP)
|
||||
if (data->buff[0] != BVLL_TYPE_BACNET_IP) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (data->buff[1]) {
|
||||
case BVLC_ORIGINAL_UNICAST_NPDU:
|
||||
|
||||
+4
-2
@@ -566,9 +566,10 @@ bool parse_cmd(int argc, char *argv[])
|
||||
current->params.mstp_params.max_master =
|
||||
(uint8_t)atoi(argv[optind]);
|
||||
if (current->params.mstp_params.max_master <
|
||||
current->route_info.mac[0])
|
||||
current->route_info.mac[0]) {
|
||||
current->params.mstp_params.max_master =
|
||||
current->route_info.mac[0];
|
||||
}
|
||||
|
||||
if (argv[optind + 1][0] != '-') {
|
||||
current->params.mstp_params.max_frames =
|
||||
@@ -778,8 +779,9 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
/* if received from another router save real source address (not other
|
||||
* router source address) */
|
||||
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
|
||||
data->src.net != addr.net)
|
||||
data->src.net != addr.net) {
|
||||
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
|
||||
}
|
||||
|
||||
/* encode both source and destination for broadcast and router-to-router
|
||||
* communication */
|
||||
|
||||
@@ -83,16 +83,18 @@ void *dl_mstp_thread(void *pArgs)
|
||||
break;
|
||||
}
|
||||
|
||||
if (port->params.mstp_params.stopbits == 2)
|
||||
if (port->params.mstp_params.stopbits == 2) {
|
||||
shared_port_data.RS485MOD |= CSTOPB;
|
||||
}
|
||||
|
||||
mstp_port.UserData = (void *)&shared_port_data;
|
||||
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
|
||||
dlmstp_set_mac_address(&mstp_port, port->route_info.mac[0]);
|
||||
dlmstp_set_max_info_frames(&mstp_port, port->params.mstp_params.max_frames);
|
||||
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
|
||||
if (!dlmstp_init(&mstp_port, port->iface))
|
||||
if (!dlmstp_init(&mstp_port, port->iface)) {
|
||||
printf("MSTP %s init failed. Stop.\n", port->iface);
|
||||
}
|
||||
|
||||
port->port_id = create_msgbox();
|
||||
if (port->port_id == INVALID_MSGBOX_ID) {
|
||||
|
||||
@@ -129,16 +129,18 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
add_dnet(&srcport->route_info, net,
|
||||
data->src); /* and update routing table */
|
||||
if (data->pdu[apdu_offset + i + 3] >
|
||||
0) /* find next NET value */
|
||||
0) { /* find next NET value */
|
||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||
else
|
||||
} else {
|
||||
i = i + 4;
|
||||
}
|
||||
}
|
||||
buff_len = create_network_message(
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
|
||||
} else
|
||||
} else {
|
||||
buff_len = create_network_message(
|
||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
|
||||
@@ -152,10 +154,11 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
add_dnet(&srcport->route_info, net,
|
||||
data->src); /* and update routing table */
|
||||
if (data->pdu[apdu_offset + i + 3] >
|
||||
0) /* find next NET value */
|
||||
0) { /* find next NET value */
|
||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||
else
|
||||
} else {
|
||||
i = i + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -202,8 +205,9 @@ uint16_t create_network_message(
|
||||
bool data_expecting_reply = false;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE)
|
||||
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE) {
|
||||
data_expecting_reply = true;
|
||||
}
|
||||
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
|
||||
|
||||
*buff = (uint8_t *)malloc(128); /* resolve different length */
|
||||
@@ -276,8 +280,9 @@ uint16_t create_network_message(
|
||||
port = port->next;
|
||||
}
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
(*buff)[buff_len++] = (uint8_t)0;
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_MESSAGE_INVALID:
|
||||
|
||||
@@ -51,16 +51,17 @@ ROUTER_PORT *find_dnet(uint16_t net, BACNET_ADDRESS *addr)
|
||||
DNET *dnet;
|
||||
|
||||
/* for broadcast messages no search is needed */
|
||||
if (net == BACNET_BROADCAST_NETWORK)
|
||||
if (net == BACNET_BROADCAST_NETWORK) {
|
||||
return port;
|
||||
}
|
||||
|
||||
while (port != NULL) {
|
||||
/* check if DNET is directly connected to the router */
|
||||
if (net == port->route_info.net)
|
||||
if (net == port->route_info.net) {
|
||||
return port;
|
||||
|
||||
/* else search router ports DNET list */
|
||||
else if (port->route_info.dnets) {
|
||||
} else if (port->route_info.dnets) {
|
||||
dnet = port->route_info.dnets;
|
||||
while (dnet != NULL) {
|
||||
if (net == dnet->net) {
|
||||
|
||||
Reference in New Issue
Block a user