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:
Kari Argillander
2024-08-30 19:20:58 +03:00
committed by GitHub
parent 622a9e609e
commit f806c5829b
547 changed files with 18286 additions and 16575 deletions
+20 -14
View File
@@ -59,8 +59,8 @@ static void MyAbortHandler(
Error_Detected = true;
}
static void MyRejectHandler(
BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
static void
MyRejectHandler(BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
{
/* FIXME: verify src and invoke id */
(void)src;
@@ -69,7 +69,8 @@ static void MyRejectHandler(
Error_Detected = true;
}
static void My_Router_Handler(BACNET_ADDRESS *src,
static void My_Router_Handler(
BACNET_ADDRESS *src,
BACNET_NPDU_DATA *npdu_data,
uint8_t *npdu, /* PDU data */
uint16_t npdu_len)
@@ -157,7 +158,8 @@ static void My_Router_Handler(BACNET_ADDRESS *src,
}
}
static void My_NPDU_Handler(BACNET_ADDRESS *src, /* source address */
static void My_NPDU_Handler(
BACNET_ADDRESS *src, /* source address */
uint8_t *pdu, /* PDU data */
uint16_t pdu_len)
{ /* length PDU */
@@ -168,7 +170,8 @@ static void My_NPDU_Handler(BACNET_ADDRESS *src, /* source address */
apdu_offset = bacnet_npdu_decode(pdu, pdu_len, &dest, src, &npdu_data);
if (npdu_data.network_layer_message) {
if (apdu_offset <= pdu_len) {
My_Router_Handler(src, &npdu_data, &pdu[apdu_offset],
My_Router_Handler(
src, &npdu_data, &pdu[apdu_offset],
(uint16_t)(pdu_len - apdu_offset));
}
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
@@ -183,7 +186,8 @@ static void My_NPDU_Handler(BACNET_ADDRESS *src, /* source address */
if (dest.net) {
debug_printf("NPDU: DNET=%d. Discarded!\n", dest.net);
} else {
debug_printf("NPDU: BACnet Protocol Version=%d. Discarded!\n",
debug_printf(
"NPDU: BACnet Protocol Version=%d. Discarded!\n",
npdu_data.protocol_version);
}
}
@@ -219,11 +223,11 @@ static void print_usage(const char *filename)
static void print_help(const char *filename)
{
printf(
"Send BACnet Initialize-Routing-Table message to a network\n"
"and wait for responses. Displays their network information.\n");
printf("Send BACnet Initialize-Routing-Table message to a network\n"
"and wait for responses. Displays their network information.\n");
printf("\n");
printf("address:\n"
printf(
"address:\n"
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\n"
"DNET ID Len Info:\n"
"Port-info data:\n"
@@ -247,8 +251,9 @@ static void address_parse(BACNET_ADDRESS *dst, int argc, char *argv[])
int index = 0;
if (argc > 0) {
count = sscanf(argv[0], "%u.%u.%u.%u:%u", &mac[0], &mac[1], &mac[2],
&mac[3], &port);
count = sscanf(
argv[0], "%u.%u.%u.%u:%u", &mac[0], &mac[1], &mac[2], &mac[3],
&port);
if (count == 5) {
dst->mac_len = 6;
for (index = 0; index < 4; index++) {
@@ -256,8 +261,9 @@ static void address_parse(BACNET_ADDRESS *dst, int argc, char *argv[])
}
encode_unsigned16(&dst->mac[4], port);
} else {
count = sscanf(argv[0], "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1],
&mac[2], &mac[3], &mac[4], &mac[5]);
count = sscanf(
argv[0], "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2],
&mac[3], &mac[4], &mac[5]);
dst->mac_len = count;
for (index = 0; index < MAX_MAC_LEN; index++) {
if (index < count) {