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
+9 -7
View File
@@ -72,7 +72,8 @@ uint32_t cobs_crc32k(uint8_t dataValue, uint32_t crc32kValue)
* @return the length of the encoded data, or 0 if error
* @note This function is copied mostly from the BACnet standard.
*/
size_t cobs_encode(uint8_t *buffer,
size_t cobs_encode(
uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length,
@@ -177,9 +178,9 @@ size_t cobs_frame_encode(
*/
crc32K = ~crc32K;
(void)cobs_crc32k_encode(crc_buffer, sizeof(crc_buffer), crc32K);
cobs_crc_len = cobs_encode((uint8_t *)(buffer + cobs_data_len),
buffer_size - cobs_data_len, crc_buffer, sizeof(crc_buffer),
MSTP_PREAMBLE_X55);
cobs_crc_len = cobs_encode(
(uint8_t *)(buffer + cobs_data_len), buffer_size - cobs_data_len,
crc_buffer, sizeof(crc_buffer), MSTP_PREAMBLE_X55);
if (cobs_crc_len == 0) {
return 0;
}
@@ -201,7 +202,8 @@ size_t cobs_frame_encode(
* @return the length of the decoded buffer, or 0 if error
* @note This function is copied directly from the BACnet standard.
*/
size_t cobs_decode(uint8_t *buffer,
size_t cobs_decode(
uint8_t *buffer,
size_t buffer_size,
const uint8_t *from,
size_t length,
@@ -294,8 +296,8 @@ size_t cobs_frame_decode(
/*
* Decode the Encoded CRC-32K field
*/
crc_len = cobs_decode(crc_buffer, sizeof(crc_buffer),
from + length - COBS_ENCODED_CRC_SIZE,
crc_len = cobs_decode(
crc_buffer, sizeof(crc_buffer), from + length - COBS_ENCODED_CRC_SIZE,
COBS_ENCODED_CRC_SIZE, MSTP_PREAMBLE_X55);
/*
* Sanity check length of decoded CRC32K.