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
+15 -14
View File
@@ -307,8 +307,8 @@ int wpm_encode_apdu_object_property(
* @param data Pointer to the data to encode.
* @return number of bytes encoded, or zero on error.
*/
int write_property_multiple_request_encode(uint8_t *apdu,
BACNET_WRITE_ACCESS_DATA *data)
int write_property_multiple_request_encode(
uint8_t *apdu, BACNET_WRITE_ACCESS_DATA *data)
{
int len = 0; /* length of each encoding */
int apdu_len = 0; /* total length of the apdu, return value */
@@ -318,8 +318,8 @@ int write_property_multiple_request_encode(uint8_t *apdu,
wpm_object = data;
while (wpm_object) {
len = wpm_encode_apdu_object_begin(apdu,
wpm_object->object_type, wpm_object->object_instance);
len = wpm_encode_apdu_object_begin(
apdu, wpm_object->object_type, wpm_object->object_instance);
apdu_len += len;
if (apdu) {
apdu += len;
@@ -330,10 +330,9 @@ int write_property_multiple_request_encode(uint8_t *apdu,
wpdata.array_index = wpm_property->propertyArrayIndex;
wpdata.priority = wpm_property->priority;
/* check length for fitting */
wpdata.application_data_len = bacapp_encode_data(
NULL, &wpm_property->value);
if (wpdata.application_data_len >
sizeof(wpdata.application_data)) {
wpdata.application_data_len =
bacapp_encode_data(NULL, &wpm_property->value);
if (wpdata.application_data_len > sizeof(wpdata.application_data)) {
/* too big for buffer */
return 0;
}
@@ -390,7 +389,8 @@ size_t write_property_multiple_request_service_encode(
* @return number of bytes encoded, or zero if unable to encode or
* too big for buffer
*/
int wpm_encode_apdu(uint8_t *apdu,
int wpm_encode_apdu(
uint8_t *apdu,
size_t apdu_size,
uint8_t invoke_id,
BACNET_WRITE_ACCESS_DATA *data)
@@ -409,7 +409,7 @@ int wpm_encode_apdu(uint8_t *apdu,
apdu += len;
}
len = write_property_multiple_request_service_encode(
apdu, apdu_size-apdu_len, data);
apdu, apdu_size - apdu_len, data);
if (len > 0) {
/* too big for buffer */
apdu_len += len;
@@ -493,7 +493,9 @@ int wpm_error_ack_encode_apdu(
* @return Count of decoded bytes.
*/
int wpm_error_ack_decode_apdu(
const uint8_t *apdu, uint16_t apdu_size, BACNET_WRITE_PROPERTY_DATA *wp_data)
const uint8_t *apdu,
uint16_t apdu_size,
BACNET_WRITE_PROPERTY_DATA *wp_data)
{
int len = 0, apdu_len = 0;
const uint8_t *apdu_offset = NULL;
@@ -618,10 +620,9 @@ int wpm_error_ack_decode_apdu(
* @brief Convert an array of BACnetWriteAccessData to linked list
* @param array pointer to element zero of the array
* @param size number of elements in the array
*/
*/
void wpm_write_access_data_link_array(
BACNET_WRITE_ACCESS_DATA *array,
size_t size)
BACNET_WRITE_ACCESS_DATA *array, size_t size)
{
size_t i = 0;