Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
+71
-40
@@ -56,7 +56,8 @@ int bvlc_encode_header(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_header(const uint8_t *pdu,
|
||||
int bvlc_decode_header(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *message_type,
|
||||
uint16_t *message_length)
|
||||
@@ -406,8 +407,7 @@ bool bvlc_broadcast_distribution_mask_from_host(
|
||||
* @return true if the broadcast distribution was retrieved
|
||||
*/
|
||||
bool bvlc_broadcast_distribution_mask_to_host(
|
||||
uint32_t *broadcast_mask,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
uint32_t *broadcast_mask, const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -521,7 +521,8 @@ bool bvlc_broadcast_distribution_table_entry_forward_address(
|
||||
* @param bdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
int bvlc_broadcast_distribution_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
{
|
||||
@@ -541,7 +542,8 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
len = encode_opening_tag(&apdu[apdu_len], 0);
|
||||
apdu_len += len;
|
||||
/* CHOICE - ip-address [1] OCTET STRING */
|
||||
octetstring_init(&octet_string, &bdt_entry->dest_address.address[0],
|
||||
octetstring_init(
|
||||
&octet_string, &bdt_entry->dest_address.address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
@@ -557,8 +559,9 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
len = encode_closing_tag(&apdu[apdu_len], 0);
|
||||
apdu_len += len;
|
||||
/* broadcast-mask [1] OCTET STRING */
|
||||
octetstring_init(&octet_string,
|
||||
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX);
|
||||
octetstring_init(
|
||||
&octet_string, &bdt_entry->broadcast_mask.address[0],
|
||||
IP_ADDRESS_MAX);
|
||||
len =
|
||||
encode_context_octet_string(&apdu[apdu_len], 1, &octet_string);
|
||||
apdu_len += len;
|
||||
@@ -584,7 +587,8 @@ int bvlc_broadcast_distribution_table_encode(uint8_t *apdu,
|
||||
* @param bdt_head - head of a BDT linked list
|
||||
* @return length of the APDU buffer decoded, or ERROR, REJECT, or ABORT
|
||||
*/
|
||||
int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
int bvlc_broadcast_distribution_table_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_head)
|
||||
@@ -698,8 +702,9 @@ int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
if (len > apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
(void)octetstring_copy_value(&bdt_entry->broadcast_mask.address[0],
|
||||
IP_ADDRESS_MAX, &octet_string);
|
||||
(void)octetstring_copy_value(
|
||||
&bdt_entry->broadcast_mask.address[0], IP_ADDRESS_MAX,
|
||||
&octet_string);
|
||||
bdt_entry->valid = true;
|
||||
/* next entry */
|
||||
bdt_entry = bdt_entry->next;
|
||||
@@ -726,7 +731,8 @@ int bvlc_broadcast_distribution_table_decode(const uint8_t *apdu,
|
||||
* BVLC Length: 2-octets L Length L, in octets, of the BVLL message
|
||||
* List of BDT Entries: N*10-octets
|
||||
*/
|
||||
int bvlc_encode_write_broadcast_distribution_table(uint8_t *pdu,
|
||||
int bvlc_encode_write_broadcast_distribution_table(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -771,7 +777,8 @@ int bvlc_encode_write_broadcast_distribution_table(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_write_broadcast_distribution_table(const uint8_t *pdu,
|
||||
int bvlc_decode_write_broadcast_distribution_table(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -856,7 +863,8 @@ int bvlc_encode_read_broadcast_distribution_table(
|
||||
* BVLC Length: 2-octets L length, in octets, of the BVLL message
|
||||
* List of BDT Entries: N*10-octets
|
||||
*/
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(uint8_t *pdu,
|
||||
int bvlc_encode_read_broadcast_distribution_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -901,7 +909,8 @@ int bvlc_encode_read_broadcast_distribution_table_ack(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(const uint8_t *pdu,
|
||||
int bvlc_decode_read_broadcast_distribution_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_list)
|
||||
{
|
||||
@@ -956,7 +965,8 @@ int bvlc_decode_read_broadcast_distribution_table_ack(const uint8_t *pdu,
|
||||
* B/IP Address of Originating Device: 6-octets
|
||||
* BACnet NPDU from Originating Device: N-octets (N=L-10)
|
||||
*/
|
||||
int bvlc_encode_forwarded_npdu(uint8_t *pdu,
|
||||
int bvlc_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_ADDRESS *bip_address,
|
||||
const uint8_t *npdu,
|
||||
@@ -999,7 +1009,8 @@ int bvlc_encode_forwarded_npdu(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_forwarded_npdu(const uint8_t *pdu,
|
||||
int bvlc_decode_forwarded_npdu(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_ADDRESS *bip_address,
|
||||
uint8_t *npdu,
|
||||
@@ -1110,7 +1121,8 @@ int bvlc_decode_register_foreign_device(
|
||||
* @param fdt_head - head of the BDT linked list
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
int bvlc_foreign_device_table_encode(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_head)
|
||||
{
|
||||
@@ -1124,7 +1136,8 @@ int bvlc_foreign_device_table_encode(uint8_t *apdu,
|
||||
while (fdt_entry) {
|
||||
if (fdt_entry->valid) {
|
||||
/* bacnetip-address [0] OCTET STRING */
|
||||
len = bvlc_encode_address(octetstring_value(&octet_string),
|
||||
len = bvlc_encode_address(
|
||||
octetstring_value(&octet_string),
|
||||
octetstring_capacity(&octet_string), &fdt_entry->dest_address);
|
||||
octetstring_truncate(&octet_string, len);
|
||||
len =
|
||||
@@ -1369,8 +1382,8 @@ uint16_t bvlc_foreign_device_table_valid_count(
|
||||
* @param bdt_list - first element in array BDT entries
|
||||
* @return number of elements of BDT entries
|
||||
*/
|
||||
uint16_t bvlc_foreign_device_table_count(
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
uint16_t
|
||||
bvlc_foreign_device_table_count(BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry = NULL;
|
||||
uint16_t entry_count = 0;
|
||||
@@ -1429,7 +1442,8 @@ void bvlc_foreign_device_table_link_array(
|
||||
* re-registration occurs. The time remaining includes the 30-second grace
|
||||
* period as defined in Clause J.5.2.3.
|
||||
*/
|
||||
int bvlc_encode_read_foreign_device_table_ack(uint8_t *pdu,
|
||||
int bvlc_encode_read_foreign_device_table_ack(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
@@ -1474,7 +1488,8 @@ int bvlc_encode_read_foreign_device_table_ack(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_read_foreign_device_table_ack(const uint8_t *pdu,
|
||||
int bvlc_decode_read_foreign_device_table_ack(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_list)
|
||||
{
|
||||
@@ -1623,7 +1638,8 @@ int bvlc_encode_distribute_broadcast_to_network(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_distribute_broadcast_to_network(const uint8_t *pdu,
|
||||
int bvlc_decode_distribute_broadcast_to_network(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1698,7 +1714,8 @@ int bvlc_encode_original_unicast(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_original_unicast(const uint8_t *pdu,
|
||||
int bvlc_decode_original_unicast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1773,7 +1790,8 @@ int bvlc_encode_original_broadcast(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_original_broadcast(const uint8_t *pdu,
|
||||
int bvlc_decode_original_broadcast(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *npdu,
|
||||
uint16_t npdu_size,
|
||||
@@ -1848,7 +1866,8 @@ int bvlc_encode_secure_bvll(
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_secure_bvll(const uint8_t *pdu,
|
||||
int bvlc_decode_secure_bvll(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
uint8_t *sbuf,
|
||||
uint16_t sbuf_size,
|
||||
@@ -2003,7 +2022,8 @@ bool bvlc_address_different(
|
||||
* @param mask - B/IPv4 broadcast distribution mask
|
||||
* @return true if the addresses are different
|
||||
*/
|
||||
bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
|
||||
bool bvlc_address_mask(
|
||||
BACNET_IP_ADDRESS *dst,
|
||||
const BACNET_IP_ADDRESS *src,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
{
|
||||
@@ -2036,7 +2056,8 @@ bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc_address_set(BACNET_IP_ADDRESS *addr,
|
||||
bool bvlc_address_set(
|
||||
BACNET_IP_ADDRESS *addr,
|
||||
uint8_t addr0,
|
||||
uint8_t addr1,
|
||||
uint8_t addr2,
|
||||
@@ -2071,7 +2092,8 @@ bool bvlc_address_set(BACNET_IP_ADDRESS *addr,
|
||||
*
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bvlc_address_get(const BACNET_IP_ADDRESS *addr,
|
||||
bool bvlc_address_get(
|
||||
const BACNET_IP_ADDRESS *addr,
|
||||
uint8_t *addr0,
|
||||
uint8_t *addr1,
|
||||
uint8_t *addr2,
|
||||
@@ -2336,7 +2358,8 @@ bool bvlc_ip_address_from_bacnet_remote(
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_broadcast_distribution_mask(uint8_t *pdu,
|
||||
int bvlc_encode_broadcast_distribution_mask(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask)
|
||||
{
|
||||
@@ -2366,7 +2389,8 @@ int bvlc_encode_broadcast_distribution_mask(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_broadcast_distribution_mask(const uint8_t *pdu,
|
||||
int bvlc_decode_broadcast_distribution_mask(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_MASK *bd_mask)
|
||||
{
|
||||
@@ -2399,7 +2423,8 @@ int bvlc_decode_broadcast_distribution_mask(const uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
int bvlc_encode_broadcast_distribution_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry)
|
||||
{
|
||||
@@ -2413,8 +2438,9 @@ int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
&pdu[offset], pdu_size - offset, &bdt_entry->dest_address);
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
len = bvlc_encode_broadcast_distribution_mask(&pdu[offset],
|
||||
pdu_size - offset, &bdt_entry->broadcast_mask);
|
||||
len = bvlc_encode_broadcast_distribution_mask(
|
||||
&pdu[offset], pdu_size - offset,
|
||||
&bdt_entry->broadcast_mask);
|
||||
}
|
||||
if (len > 0) {
|
||||
offset += len;
|
||||
@@ -2440,7 +2466,8 @@ int bvlc_encode_broadcast_distribution_table_entry(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_broadcast_distribution_table_entry(const uint8_t *pdu,
|
||||
int bvlc_decode_broadcast_distribution_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_BROADCAST_DISTRIBUTION_TABLE_ENTRY *bdt_entry)
|
||||
{
|
||||
@@ -2480,7 +2507,8 @@ int bvlc_decode_broadcast_distribution_table_entry(const uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int bvlc_encode_foreign_device_table_entry(uint8_t *pdu,
|
||||
int bvlc_encode_foreign_device_table_entry(
|
||||
uint8_t *pdu,
|
||||
uint16_t pdu_size,
|
||||
const BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
{
|
||||
@@ -2524,7 +2552,8 @@ int bvlc_encode_foreign_device_table_entry(uint8_t *pdu,
|
||||
*
|
||||
* @return number of bytes decoded
|
||||
*/
|
||||
int bvlc_decode_foreign_device_table_entry(const uint8_t *pdu,
|
||||
int bvlc_decode_foreign_device_table_entry(
|
||||
const uint8_t *pdu,
|
||||
uint16_t pdu_len,
|
||||
BACNET_IP_FOREIGN_DEVICE_TABLE_ENTRY *fdt_entry)
|
||||
{
|
||||
@@ -2626,7 +2655,8 @@ int bvlc_foreign_device_bbmd_host_address_encode(
|
||||
* @param ip_address - IP address and port number
|
||||
* @return length of the APDU buffer decoded, or ERROR, REJECT, or ABORT
|
||||
*/
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(const uint8_t *apdu,
|
||||
int bvlc_foreign_device_bbmd_host_address_decode(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
BACNET_ERROR_CODE *error_code,
|
||||
BACNET_IP_ADDRESS *ip_address)
|
||||
@@ -2638,8 +2668,9 @@ int bvlc_foreign_device_bbmd_host_address_decode(const uint8_t *apdu,
|
||||
if (len > 0) {
|
||||
if (address.host_ip_address) {
|
||||
ip_address->port = address.port;
|
||||
(void)octetstring_copy_value(&ip_address->address[0],
|
||||
IP_ADDRESS_MAX, &address.host.ip_address);
|
||||
(void)octetstring_copy_value(
|
||||
&ip_address->address[0], IP_ADDRESS_MAX,
|
||||
&address.host.ip_address);
|
||||
} else {
|
||||
len = BACNET_STATUS_REJECT;
|
||||
if (error_code) {
|
||||
|
||||
Reference in New Issue
Block a user