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
+39 -27
View File
@@ -57,7 +57,8 @@ static bool Error_Detected = false;
/* Used for verbose */
static bool Verbose = false;
static void MyRemoveListElementErrorHandler(BACNET_ADDRESS *src,
static void MyRemoveListElementErrorHandler(
BACNET_ADDRESS *src,
uint8_t invoke_id,
uint8_t service_choice,
uint8_t *service_request,
@@ -72,7 +73,8 @@ static void MyRemoveListElementErrorHandler(BACNET_ADDRESS *src,
len = list_element_error_ack_decode(
service_request, service_len, &list_element);
if (len > 0) {
printf("BACnet Error: %s: %s [first-failed=%u]\n",
printf(
"BACnet Error: %s: %s [first-failed=%u]\n",
bactext_error_class_name((int)list_element.error_class),
bactext_error_code_name((int)list_element.error_code),
(unsigned)list_element.first_failed_element_number);
@@ -81,8 +83,8 @@ static void MyRemoveListElementErrorHandler(BACNET_ADDRESS *src,
}
}
static void MyRemoveListElementSimpleAckHandler(
BACNET_ADDRESS *src, uint8_t invoke_id)
static void
MyRemoveListElementSimpleAckHandler(BACNET_ADDRESS *src, uint8_t invoke_id)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID)) {
@@ -102,13 +104,14 @@ static void MyAbortHandler(
}
}
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 */
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;
}
@@ -130,7 +133,8 @@ static void Init_Service_Handlers(void)
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
/* handle the ack or error coming back from confirmed request */
apdu_set_confirmed_simple_ack_handler(
SERVICE_CONFIRMED_ADD_LIST_ELEMENT, MyRemoveListElementSimpleAckHandler);
SERVICE_CONFIRMED_ADD_LIST_ELEMENT,
MyRemoveListElementSimpleAckHandler);
apdu_set_complex_error_handler(
SERVICE_CONFIRMED_ADD_LIST_ELEMENT, MyRemoveListElementErrorHandler);
apdu_set_abort_handler(MyAbortHandler);
@@ -139,8 +143,9 @@ static void Init_Service_Handlers(void)
static void print_usage(const char *filename)
{
printf("Usage: %s device-instance object-type object-instance "
"property array-index tag value\n",
printf(
"Usage: %s device-instance object-type object-instance "
"property array-index tag value\n",
filename);
printf(" [--dnet][--dadr][--mac]\n");
printf(" [--version][--help][--verbose]\n");
@@ -211,10 +216,11 @@ static void print_help(const char *filename)
"the Any property type in the schedule object and the Present Value\n"
"accepting REAL, BOOLEAN, NULL, etc.\n");
printf("\n");
printf("Example:\n"
"If you want to RemoveListElement to the Recipient-List property in\n"
"Notification Class 1 of Device 123, send the following command:\n"
"%s 123 15 1 102 -1 4 100\n",
printf(
"Example:\n"
"If you want to RemoveListElement to the Recipient-List property in\n"
"Notification Class 1 of Device 123, send the following command:\n"
"%s 123 15 1 102 -1 4 100\n",
filename);
}
@@ -287,8 +293,8 @@ int main(int argc, char *argv[])
if (target_args == 0) {
object_instance = strtoul(argv[argi], NULL, 0);
if (object_instance > BACNET_MAX_INSTANCE) {
fprintf(stderr,
"device-instance=%u - not greater than %u\n",
fprintf(
stderr, "device-instance=%u - not greater than %u\n",
object_instance, BACNET_MAX_INSTANCE);
return 1;
}
@@ -305,8 +311,8 @@ int main(int argc, char *argv[])
} else if (target_args == 2) {
object_instance = strtoul(argv[argi], NULL, 0);
if (object_instance > BACNET_MAX_INSTANCE) {
fprintf(stderr,
"device-instance=%u - not greater than %u\n",
fprintf(
stderr, "device-instance=%u - not greater than %u\n",
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
return 1;
}
@@ -330,7 +336,8 @@ int main(int argc, char *argv[])
property_array_index = strtol(argv[argi], NULL, 0);
Target_Object_Array_Index = property_array_index;
if (Verbose) {
printf("Array_Index=%i=%s\n", property_array_index,
printf(
"Array_Index=%i=%s\n", property_array_index,
argv[argi]);
}
target_args++;
@@ -357,14 +364,16 @@ int main(int argc, char *argv[])
} else if (tag_value_arg == 1) {
value_string = argv[argi];
if (Verbose) {
printf("tag=%ld value=%s\n", property_tag, value_string);
printf(
"tag=%ld value=%s\n", property_tag, value_string);
}
if (property_tag < 0) {
/* find the application tag for internal properties */
property_tag = bacapp_known_property_tag(
Target_Object_Type, Target_Object_Property);
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
fprintf(stderr,
fprintf(
stderr,
"Error: tag=%ld - it must be less than %u\n",
property_tag, MAX_BACNET_APPLICATION_TAG);
return 1;
@@ -374,13 +383,15 @@ int main(int argc, char *argv[])
status = bacapp_parse_application_data(
property_tag, value_string, application_value);
if (!status) {
fprintf(stderr,
fprintf(
stderr,
"Error: unable to parse the tag value\n");
return 1;
}
} else {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr,
fprintf(
stderr,
"Error: unable to parse the known property"
" \"%s\"\r\n",
value_string);
@@ -400,8 +411,7 @@ int main(int argc, char *argv[])
return 0;
}
if (tag_value_arg != 0) {
fprintf(
stderr, "Error: invalid tag+value pair (%i).\n", tag_value_arg);
fprintf(stderr, "Error: invalid tag+value pair (%i).\n", tag_value_arg);
return 1;
}
/* setup my info */
@@ -422,7 +432,8 @@ int main(int argc, char *argv[])
Target_Device_Object_Instance, &max_apdu, &Target_Address);
if (found) {
if (Verbose) {
printf("Found Device %u in address_cache.\n",
printf(
"Found Device %u in address_cache.\n",
Target_Device_Object_Instance);
}
} else {
@@ -435,7 +446,8 @@ int main(int argc, char *argv[])
/* device is bound! */
if (Request_Invoke_ID == 0) {
if (Verbose) {
printf("Sending RemoveListElement to Device %u.\n",
printf(
"Sending RemoveListElement to Device %u.\n",
Target_Device_Object_Instance);
}
Request_Invoke_ID = Send_Remove_List_Element_Request(