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
+22 -23
View File
@@ -41,12 +41,14 @@ static bitstring_value_write_present_value_callback
BitString_Value_Write_Present_Value_Callback;
/* These three arrays are used by the ReadPropertyMultiple handler */
static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
-1 };
static const int Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int Properties_Optional[] = { PROP_RELIABILITY,
PROP_OUT_OF_SERVICE, PROP_DESCRIPTION, -1 };
PROP_OUT_OF_SERVICE,
PROP_DESCRIPTION, -1 };
static const int Properties_Proprietary[] = { -1 };
@@ -265,8 +267,7 @@ bool BitString_Value_Out_Of_Service(uint32_t object_instance)
* @param object_instance - object-instance number of the object
* @param true/false
*/
void BitString_Value_Out_Of_Service_Set(
uint32_t object_instance, bool value)
void BitString_Value_Out_Of_Service_Set(uint32_t object_instance, bool value)
{
struct object_data *pObject;
@@ -286,8 +287,7 @@ void BitString_Value_Out_Of_Service_Set(
* @param object_instance - object-instance number of the object
* @return BACNET_RELIABILITY value
*/
BACNET_RELIABILITY BitString_Value_Reliablity(
uint32_t object_instance)
BACNET_RELIABILITY BitString_Value_Reliablity(uint32_t object_instance)
{
BACNET_RELIABILITY value = RELIABILITY_NO_FAULT_DETECTED;
struct object_data *pObject;
@@ -298,7 +298,6 @@ BACNET_RELIABILITY BitString_Value_Reliablity(
}
return value;
}
/**
@@ -411,8 +410,8 @@ bool BitString_Value_Encode_Value_List(
pObject = BitString_Value_Object(object_instance);
if (pObject) {
status = cov_value_list_encode_bit_string(value_list,
&pObject->Present_Value, in_alarm, fault, overridden,
status = cov_value_list_encode_bit_string(
value_list, &pObject->Present_Value, in_alarm, fault, overridden,
pObject->Out_Of_Service);
}
@@ -442,7 +441,8 @@ bool BitString_Value_Object_Name(
status =
characterstring_init_ansi(object_name, pObject->Object_Name);
} else {
snprintf(name_text, sizeof(name_text), "BITSTRING_VALUE-%u",
snprintf(
name_text, sizeof(name_text), "BITSTRING_VALUE-%u",
object_instance);
status = characterstring_init_ansi(object_name, name_text);
}
@@ -562,8 +562,8 @@ int BitString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
apdu = rpdata->application_data;
switch (rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER:
apdu_len = encode_application_object_id(&apdu[0],
OBJECT_BITSTRING_VALUE, rpdata->object_instance);
apdu_len = encode_application_object_id(
&apdu[0], OBJECT_BITSTRING_VALUE, rpdata->object_instance);
break;
case PROP_OBJECT_NAME:
if (BitString_Value_Object_Name(
@@ -574,13 +574,13 @@ int BitString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
break;
case PROP_DESCRIPTION:
characterstring_init_ansi(
&char_string, BitString_Value_Description(
rpdata->object_instance));
&char_string,
BitString_Value_Description(rpdata->object_instance));
apdu_len = encode_application_character_string(apdu, &char_string);
break;
case PROP_OBJECT_TYPE:
apdu_len = encode_application_enumerated(
&apdu[0], OBJECT_BITSTRING_VALUE);
apdu_len =
encode_application_enumerated(&apdu[0], OBJECT_BITSTRING_VALUE);
break;
case PROP_PRESENT_VALUE:
BitString_Value_Present_Value(rpdata->object_instance, &bit_string);
@@ -602,9 +602,8 @@ int BitString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
apdu_len = encode_application_boolean(&apdu[0], state);
break;
case PROP_RELIABILITY:
apdu_len =
encode_application_enumerated(&apdu[0],
BitString_Value_Reliablity(rpdata->object_instance));
apdu_len = encode_application_enumerated(
&apdu[0], BitString_Value_Reliablity(rpdata->object_instance));
break;
default:
rpdata->error_class = ERROR_CLASS_PROPERTY;
@@ -684,8 +683,8 @@ bool BitString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
default:
if (property_lists_member(
Properties_Required, Properties_Optional,
Properties_Proprietary, wp_data->object_property)) {
Properties_Required, Properties_Optional,
Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {