Enabled style and CERT-C addon for CPPCHECK (#869)

* Enabled style and CERT-C addon for CPPCHECK with some suppressions and fixed the defects found..
This commit is contained in:
Steve Karg
2024-12-10 07:56:24 -06:00
committed by GitHub
parent f38b75b389
commit d4cbec91e2
21 changed files with 79 additions and 73 deletions
+3 -6
View File
@@ -446,19 +446,16 @@ BSC_SC_RET bsc_hub_connector_start(
"bsc_hub_connector_start() <<< ret = BSC_SC_NO_RESOURCES\n");
return BSC_SC_NO_RESOURCES;
}
c->reconnect_timeout_s = reconnect_timeout_s;
c->primary_url[0] = 0;
c->failover_url[0] = 0;
c->user_arg = user_arg;
strcpy((char *)c->primary_url, primaryURL);
strncpy((char *)c->primary_url, primaryURL, sizeof(c->primary_url) - 1);
if (failoverURL) {
strcpy((char *)c->failover_url, failoverURL);
strncpy(
(char *)c->failover_url, failoverURL, sizeof(c->failover_url) - 1);
}
c->event_func = event_func;
bsc_init_ctx_cfg(
BSC_SOCKET_CTX_INITIATOR, &c->cfg, BSC_WEBSOCKET_HUB_PROTOCOL, 0, NULL,
ca_cert_chain, ca_cert_chain_size, cert_chain, cert_chain_size, key,
+6 -3
View File
@@ -267,9 +267,10 @@ copy_urls(BSC_NODE_SWITCH_CTX *ctx, int index, BSC_ADDRESS_RESOLUTION *r)
int i;
for (i = 0; i < r->urls_num; i++) {
ctx->initiator.urls[index].utf8_urls[i][0] = 0;
strcpy(
strncpy(
(char *)&ctx->initiator.urls[index].utf8_urls[i][0],
(char *)&r->utf8_urls[i][0]);
(char *)&r->utf8_urls[i][0],
sizeof(ctx->initiator.urls[index].utf8_urls[i]) - 1);
}
ctx->initiator.urls[index].urls_cnt = r->urls_num;
}
@@ -287,7 +288,9 @@ copy_urls2(BSC_NODE_SWITCH_CTX *ctx, int index, char **urls, size_t urls_cnt)
size_t i;
for (i = 0; i < urls_cnt; i++) {
ctx->initiator.urls[index].utf8_urls[i][0] = 0;
strcpy((char *)&ctx->initiator.urls[index].utf8_urls[i][0], urls[i]);
strncpy(
(char *)&ctx->initiator.urls[index].utf8_urls[i][0], urls[i],
sizeof(ctx->initiator.urls[index].utf8_urls[i]) - 1);
}
ctx->initiator.urls[index].urls_cnt = urls_cnt;
}
+2 -3
View File
@@ -470,8 +470,7 @@ static void bsc_node_process_received(
buf, sizeof(buf), decoded_pdu->hdr.message_id, NULL,
decoded_pdu->hdr.origin, decoded_pdu->hdr.bvlc_function, 1,
&decoded_pdu->dest_options[i].packed_header_marker,
&error_class, &error_code,
(uint8_t *)ERROR_STR_OPTION_NOT_UNDERSTOOD);
&error_class, &error_code, ERROR_STR_OPTION_NOT_UNDERSTOOD);
if (bufsize) {
ret = bsc_node_send(node, buf, bufsize);
#if DEBUG_ENABLED == 1
@@ -587,7 +586,7 @@ static void bsc_node_process_received(
buf, sizeof(buf), decoded_pdu->hdr.message_id, NULL,
decoded_pdu->hdr.origin, decoded_pdu->hdr.bvlc_function, 1,
NULL, &error_class, &error_code,
(uint8_t *)ERROR_STR_DIRECT_CONNECTIONS_NOT_SUPPORTED);
ERROR_STR_DIRECT_CONNECTIONS_NOT_SUPPORTED);
if (bufsize) {
ret = bsc_node_send(node, buf, bufsize);
#if DEBUG_ENABLED == 1
+8 -10
View File
@@ -240,7 +240,7 @@ static bool bsc_prepare_error_extended(
uint8_t *error_header_marker,
BACNET_ERROR_CLASS error_class,
BACNET_ERROR_CODE error_code,
uint8_t *utf8_details_string)
const uint8_t *utf8_details_string)
{
uint16_t eclass = (uint16_t)error_class;
uint16_t ecode = (uint16_t)error_code;
@@ -318,7 +318,7 @@ static bool bsc_prepare_protocol_error_extended(
uint8_t *error_header_marker,
BACNET_ERROR_CLASS error_class,
BACNET_ERROR_CODE error_code,
uint8_t *utf8_details_string)
const uint8_t *utf8_details_string)
{
if (bvlc_sc_need_send_bvlc_result(dm)) {
return bsc_prepare_error_extended(
@@ -346,7 +346,7 @@ static bool bsc_prepare_protocol_error(
BACNET_SC_VMAC_ADDRESS *dest,
BACNET_ERROR_CLASS error_class,
BACNET_ERROR_CODE error_code,
uint8_t *utf8_details_string)
const uint8_t *utf8_details_string)
{
return bsc_prepare_protocol_error_extended(
c, dm, origin, dest, NULL, error_class, error_code,
@@ -588,8 +588,7 @@ static void bsc_process_socket_state(
if ((code != ERROR_CODE_DISCARD) &&
(class != ERROR_CLASS_COMMUNICATION)) {
*need_send = bsc_prepare_protocol_error(
c, dm, dm->hdr.origin, dm->hdr.dest, class, code,
(uint8_t *)err_desc);
c, dm, dm->hdr.origin, dm->hdr.dest, class, code, err_desc);
}
#if DEBUG_BSC_SOCKET == 1
else {
@@ -620,7 +619,7 @@ static void bsc_process_socket_state(
*need_send = bsc_prepare_protocol_error(
c, dm, NULL, &c->vmac, class, code,
(uint8_t *)s_error_no_origin);
s_error_no_origin);
valid = false;
} else if (
dm->hdr.dest != NULL &&
@@ -629,7 +628,7 @@ static void bsc_process_socket_state(
code = ERROR_CODE_HEADER_ENCODING_ERROR;
*need_send = bsc_prepare_protocol_error(
c, dm, NULL, &c->vmac, class, code,
(uint8_t *)s_error_dest_presented);
s_error_dest_presented);
valid = false;
}
} else if (
@@ -642,15 +641,14 @@ static void bsc_process_socket_state(
code = ERROR_CODE_HEADER_ENCODING_ERROR;
*need_send = bsc_prepare_protocol_error(
c, dm, NULL, NULL, class, code,
(uint8_t *)s_error_no_dest);
c, dm, NULL, NULL, class, code, s_error_no_dest);
valid = false;
} else if (dm->hdr.origin != NULL) {
class = ERROR_CLASS_COMMUNICATION;
code = ERROR_CODE_HEADER_ENCODING_ERROR;
*need_send = bsc_prepare_protocol_error(
c, dm, NULL, NULL, class, code,
(uint8_t *)s_error_origin_presented);
s_error_origin_presented);
valid = false;
}
}
+2 -2
View File
@@ -738,7 +738,7 @@ size_t bvlc_sc_encode_result(
uint8_t *error_header_marker,
uint16_t *error_class,
uint16_t *error_code,
uint8_t *utf8_details_string)
const uint8_t *utf8_details_string)
{
size_t offs;
@@ -1803,7 +1803,7 @@ static bool bvlc_sc_decode_hdr(
offs += hdr_opt_len;
}
if (message_len - offs <= 0) {
if (offs >= message_len) {
/* no payload */
return true;
}
+1 -1
View File
@@ -285,7 +285,7 @@ size_t bvlc_sc_encode_result(
uint8_t *error_header_marker,
uint16_t *error_class,
uint16_t *error_code,
uint8_t *utf8_details_string);
const uint8_t *utf8_details_string);
BACNET_STACK_EXPORT
size_t bvlc_sc_encode_encapsulated_npdu(
+1 -1
View File
@@ -1587,7 +1587,7 @@ static void MSTP_Zero_Config_State_Confirm(struct mstp_port_struct_t *mstp_port)
if (dst == mstp_port->Zero_Config_Station) {
match = true;
}
if (match & (mstp_port->DataLength < MSTP_UUID_SIZE)) {
if (match && (mstp_port->DataLength < MSTP_UUID_SIZE)) {
match = false;
}
if (match &&