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
+38 -31
View File
@@ -51,14 +51,16 @@ static bool Error_Detected = false;
* @param error_class [in] the error class
* @param error_code [in] the error code
*/
static void MyErrorHandler(BACNET_ADDRESS *src,
static void MyErrorHandler(
BACNET_ADDRESS *src,
uint8_t invoke_id,
BACNET_ERROR_CLASS error_class,
BACNET_ERROR_CODE error_code)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) {
printf("BACnet Error: %s: %s\n",
printf(
"BACnet Error: %s: %s\n",
bactext_error_class_name((int)error_class),
bactext_error_code_name((int)error_code));
Error_Detected = true;
@@ -90,12 +92,13 @@ static void MyAbortHandler(
* @param invoke_id [in] the invokeID from the rejected message
* @param reject_reason [in] the reason for the rejection
*/
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)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) {
printf("BACnet Reject: %s\n",
printf(
"BACnet Reject: %s\n",
bactext_reject_reason_name((int)reject_reason));
Error_Detected = true;
}
@@ -106,8 +109,8 @@ static void MyRejectHandler(
* @param src [in] BACNET_ADDRESS of the source of the message
* @param invoke_id [in] the invokeID from the rejected message
*/
static void MyWritePropertySimpleAckHandler(
BACNET_ADDRESS *src, uint8_t invoke_id)
static void
MyWritePropertySimpleAckHandler(BACNET_ADDRESS *src, uint8_t invoke_id)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) {
@@ -143,9 +146,10 @@ static void Init_Service_Handlers(void)
static void print_usage(const char *filename)
{
printf("Usage: %s device-id process-id\n"
" event-object-type event-object-instance event-state-acked\n"
" event-time-stamp ack-source-name ack-time-stamp\n",
printf(
"Usage: %s device-id process-id\n"
" event-object-type event-object-instance event-state-acked\n"
" event-time-stamp ack-source-name ack-time-stamp\n",
filename);
printf(" [--dnet][--dadr][--mac]\n");
printf(" [--version][--help]\n");
@@ -154,51 +158,53 @@ static void print_usage(const char *filename)
static void print_help(const char *filename)
{
printf("Send BACnet AcknowledgedAlarm, message to a device.\n");
printf("device-id:\n"
printf(
"device-id:\n"
"BACnet Device Object Instance number that you are trying to\n"
"communicate to. This number will be used to try and bind with\n"
"the device using Who-Is and I-Am services. For example, if you were\n"
"notifying Device Object 123, the device-instance would be 123.\n");
printf("\n");
printf("process-id:\n"
"Process Identifier in the receiving device for which the\n"
"notification is intended.\n");
"Process Identifier in the receiving device for which the\n"
"notification is intended.\n");
printf("\n");
printf("event-object-type:\n"
printf(
"event-object-type:\n"
"The object type is defined either as the object-type name string\n"
"as defined in the BACnet specification, or as the integer value.\n");
printf("\n");
printf("event-object-instance:\n"
"The object instance number of the event object.\n");
"The object instance number of the event object.\n");
printf("\n");
printf("event-state-acked:\n"
"The event-state that for this alarm acknowledge.\n");
"The event-state that for this alarm acknowledge.\n");
printf("\n");
printf("event-time-stamp:\n"
"The time-stamp of the event.\n");
"The time-stamp of the event.\n");
printf("\n");
printf("ack-source-name\n"
"The source name of the alarm acknowledge.\n");
"The source name of the alarm acknowledge.\n");
printf("\n");
printf("ack-time-stamp\n"
"The time-stamp of the alarm acknowledge.\n");
"The time-stamp of the alarm acknowledge.\n");
printf("\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.\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.\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");
(void)filename;
}
@@ -345,7 +351,8 @@ int main(int argc, char *argv[])
dest.len = 0;
}
address_add(Target_Device_Object_Instance, MAX_APDU, &dest);
printf("Added Device %u to address cache\n",
printf(
"Added Device %u to address cache\n",
Target_Device_Object_Instance);
}
/* setup my info */