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 -10
View File
@@ -141,7 +141,8 @@ bool dcc_set_status_duration(
*
* @return Bytes encoded or zero on an error.
*/
int dcc_apdu_encode(uint8_t *apdu,
int dcc_apdu_encode(
uint8_t *apdu,
uint16_t timeDuration,
BACNET_COMMUNICATION_ENABLE_DISABLE enable_disable,
const BACNET_CHARACTER_STRING *password)
@@ -183,7 +184,8 @@ int dcc_apdu_encode(uint8_t *apdu,
* @param password Pointer to an optional password.
* @return number of bytes encoded, or zero if unable to encode or too large
*/
size_t dcc_service_request_encode(uint8_t *apdu,
size_t dcc_service_request_encode(
uint8_t *apdu,
size_t apdu_size,
uint16_t timeDuration,
BACNET_COMMUNICATION_ENABLE_DISABLE enable_disable,
@@ -212,7 +214,8 @@ size_t dcc_service_request_encode(uint8_t *apdu,
* @param password Pointer to an optional password, NULL=optional
* @return Bytes encoded or zero on an error.
*/
int dcc_encode_apdu(uint8_t *apdu,
int dcc_encode_apdu(
uint8_t *apdu,
uint8_t invoke_id,
uint16_t timeDuration,
BACNET_COMMUNICATION_ENABLE_DISABLE enable_disable,
@@ -232,8 +235,7 @@ int dcc_encode_apdu(uint8_t *apdu,
if (apdu) {
apdu += len;
}
len = dcc_apdu_encode(
apdu, timeDuration, enable_disable, password);
len = dcc_apdu_encode(apdu, timeDuration, enable_disable, password);
apdu_len += len;
return apdu_len;
@@ -252,7 +254,8 @@ int dcc_encode_apdu(uint8_t *apdu,
*
* @return Bytes decoded, or BACNET_STATUS_ABORT or BACNET_STATUS_REJECT
*/
int dcc_decode_service_request(const uint8_t *apdu,
int dcc_decode_service_request(
const uint8_t *apdu,
unsigned apdu_len_max,
uint16_t *timeDuration,
BACNET_COMMUNICATION_ENABLE_DISABLE *enable_disable,
@@ -308,13 +311,15 @@ int dcc_decode_service_request(const uint8_t *apdu,
context tag number or result in an error */
return BACNET_STATUS_ABORT;
}
len = bacnet_tag_number_and_value_decode(&apdu[apdu_len],
apdu_len_max - apdu_len, &tag_number, &len_value_type);
len = bacnet_tag_number_and_value_decode(
&apdu[apdu_len], apdu_len_max - apdu_len, &tag_number,
&len_value_type);
if (len > 0) {
apdu_len += len;
if ((unsigned)apdu_len < apdu_len_max) {
len = bacnet_character_string_decode(&apdu[apdu_len],
apdu_len_max - apdu_len, len_value_type, password);
len = bacnet_character_string_decode(
&apdu[apdu_len], apdu_len_max - apdu_len,
len_value_type, password);
if (len > 0) {
password_length = len_value_type - 1;
if ((password_length >= 1) && (password_length <= 20)) {