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
+31 -27
View File
@@ -50,8 +50,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)
{
(void)src;
(void)invoke_id;
@@ -80,7 +80,8 @@ static void Init_Service_Handlers(void)
static void print_usage(const char *filename)
{
printf("Usage: %s [device-instance vendor-id max-apdu segmentation]\n",
printf(
"Usage: %s [device-instance vendor-id max-apdu segmentation]\n",
filename);
printf(" [--dnet][--dadr][--mac]\n");
printf(" [--version][--help]\n");
@@ -90,47 +91,49 @@ static void print_help(const char *filename)
{
printf("Send BACnet I-Am message for a device.\n");
printf("--mac A\n"
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
printf("\n");
printf("--dnet N\n"
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n");
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n");
printf("\n");
printf("--dadr A\n"
"Optional BACnet mac address on the destination BACnet network number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
"Optional BACnet mac address on the destination BACnet network "
"number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
printf("\n");
printf("--repeat\n"
"Send the message repeatedly until signalled to quit.\n"
"Default is to not repeat, sending only a single message.\n");
"Send the message repeatedly until signalled to quit.\n"
"Default is to not repeat, sending only a single message.\n");
printf("\n");
printf("--retry C\n"
"Send the message C number of times\n"
"Default is retry 0, only sending one time.\n");
"Send the message C number of times\n"
"Default is retry 0, only sending one time.\n");
printf("\n");
printf("--delay\n"
"Delay, in milliseconds, between repeated messages.\n"
"Default delay is 100ms.\n");
"Delay, in milliseconds, between repeated messages.\n"
"Default delay is 100ms.\n");
printf("\n");
printf("device-instance:\n"
"BACnet device-ID 0..4194303\n");
"BACnet device-ID 0..4194303\n");
printf("\n");
printf("vendor-id:\n"
"Vendor Identifier 0..65535\n");
"Vendor Identifier 0..65535\n");
printf("\n");
printf("max-apdu:\n"
"Maximum APDU size 50..65535\n");
"Maximum APDU size 50..65535\n");
printf("\n");
printf("segmentation:\n"
"BACnet Segmentation 0=both, 1=transmit, 2=receive, 3=none\n");
"BACnet Segmentation 0=both, 1=transmit, 2=receive, 3=none\n");
printf("\n");
printf("Example:\n"
printf(
"Example:\n"
"To send an I-Am message of instance=1234 vendor-id=260 max-apdu=480\n"
"%s 1234 260 480\n",
filename);
@@ -258,8 +261,9 @@ int main(int argc, char *argv[])
atexit(datalink_cleanup);
/* send the request */
do {
Send_I_Am_To_Network(&dest, Target_Device_ID, Target_Max_APDU,
Target_Segmentation, Target_Vendor_ID);
Send_I_Am_To_Network(
&dest, Target_Device_ID, Target_Max_APDU, Target_Segmentation,
Target_Vendor_ID);
if (repeat_forever || retry_count) {
/* returns 0 bytes on timeout */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);