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:
@@ -42,15 +42,19 @@ static const BACNET_OBJECT_TYPE Object_Type = OBJECT_MULTI_STATE_INPUT;
|
||||
static multistate_input_write_present_value_callback
|
||||
Multistate_Input_Write_Present_Value_Callback;
|
||||
/* default state text when none is specified */
|
||||
static const char *Default_State_Text = "State 1\0" "State 2\0" "State 3\0" ;
|
||||
static const char *Default_State_Text = "State 1\0"
|
||||
"State 2\0"
|
||||
"State 3\0";
|
||||
|
||||
/* 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,
|
||||
PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1 };
|
||||
static const int Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1
|
||||
};
|
||||
|
||||
static const int Properties_Optional[] = { PROP_DESCRIPTION, PROP_STATE_TEXT,
|
||||
-1 };
|
||||
-1 };
|
||||
|
||||
static const int Properties_Proprietary[] = { -1 };
|
||||
|
||||
@@ -215,8 +219,8 @@ uint32_t Multistate_Input_Max_States(uint32_t object_instance)
|
||||
* @param state_index - state index number 1..N of the text requested
|
||||
* @return C string retrieved
|
||||
*/
|
||||
const char *Multistate_Input_State_Text(
|
||||
uint32_t object_instance, uint32_t state_index)
|
||||
const char *
|
||||
Multistate_Input_State_Text(uint32_t object_instance, uint32_t state_index)
|
||||
{
|
||||
const char *pName = NULL; /* return value */
|
||||
const struct object_data *pObject;
|
||||
@@ -224,8 +228,7 @@ const char *Multistate_Input_State_Text(
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
if (state_index > 0) {
|
||||
pName = state_name_by_index(pObject->State_Text,
|
||||
state_index);
|
||||
pName = state_name_by_index(pObject->State_Text, state_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +257,7 @@ static int Multistate_Input_State_Text_Encode(
|
||||
pName = Multistate_Input_State_Text(object_instance, state_index);
|
||||
if (pName) {
|
||||
characterstring_init_ansi(&char_string, pName);
|
||||
apdu_len = encode_application_character_string(
|
||||
apdu, &char_string);
|
||||
apdu_len = encode_application_character_string(apdu, &char_string);
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
@@ -280,8 +282,7 @@ static int Multistate_Input_State_Text_Encode(
|
||||
* @return true if the state text was set
|
||||
*/
|
||||
bool Multistate_Input_State_Text_List_Set(
|
||||
uint32_t object_instance,
|
||||
const char *state_text_list)
|
||||
uint32_t object_instance, const char *state_text_list)
|
||||
{
|
||||
bool status = false;
|
||||
struct object_data *pObject;
|
||||
@@ -365,7 +366,8 @@ bool Multistate_Input_Present_Value_Set(
|
||||
* @return true if values are within range and present-value is set.
|
||||
*/
|
||||
static bool Multistate_Input_Present_Value_Write(
|
||||
uint32_t object_instance, uint32_t value,
|
||||
uint32_t object_instance,
|
||||
uint32_t value,
|
||||
BACNET_ERROR_CLASS *error_class,
|
||||
BACNET_ERROR_CODE *error_code)
|
||||
{
|
||||
@@ -437,8 +439,8 @@ void Multistate_Input_Out_Of_Service_Set(uint32_t object_instance, bool value)
|
||||
|
||||
pObject = Multistate_Input_Object(object_instance);
|
||||
if (pObject) {
|
||||
pObject->Out_Of_Service = value;
|
||||
pObject->Change_Of_Value = true;
|
||||
pObject->Out_Of_Service = value;
|
||||
pObject->Change_Of_Value = true;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -463,10 +465,11 @@ bool Multistate_Input_Object_Name(
|
||||
pObject = Multistate_Input_Object(object_instance);
|
||||
if (pObject) {
|
||||
if (pObject->Object_Name) {
|
||||
status = characterstring_init_ansi(object_name,
|
||||
pObject->Object_Name);
|
||||
status =
|
||||
characterstring_init_ansi(object_name, pObject->Object_Name);
|
||||
} else {
|
||||
snprintf(name_text, sizeof(name_text), "MULTI-STATE INPUT %lu",
|
||||
snprintf(
|
||||
name_text, sizeof(name_text), "MULTI-STATE INPUT %lu",
|
||||
(unsigned long)object_instance);
|
||||
status = characterstring_init_ansi(object_name, name_text);
|
||||
}
|
||||
@@ -682,9 +685,9 @@ bool Multistate_Input_Encode_Value_List(
|
||||
pObject = Multistate_Input_Object(object_instance);
|
||||
if (pObject) {
|
||||
fault = Multistate_Input_Object_Fault(pObject);
|
||||
status =
|
||||
cov_value_list_encode_unsigned(value_list, pObject->Present_Value,
|
||||
in_alarm, fault, overridden, pObject->Out_Of_Service);
|
||||
status = cov_value_list_encode_unsigned(
|
||||
value_list, pObject->Present_Value, in_alarm, fault, overridden,
|
||||
pObject->Out_Of_Service);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -725,8 +728,7 @@ int Multistate_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Object_Type);
|
||||
apdu_len = encode_application_enumerated(&apdu[0], Object_Type);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
present_value =
|
||||
@@ -745,7 +747,8 @@ int Multistate_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0],
|
||||
Multistate_Input_Reliability(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -758,14 +761,16 @@ int Multistate_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_NUMBER_OF_STATES:
|
||||
apdu_len = encode_application_unsigned(&apdu[apdu_len],
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[apdu_len],
|
||||
Multistate_Input_Max_States(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_STATE_TEXT:
|
||||
max_states = Multistate_Input_Max_States(rpdata->object_instance);
|
||||
apdu_len = bacnet_array_encode(rpdata->object_instance,
|
||||
rpdata->array_index, Multistate_Input_State_Text_Encode,
|
||||
max_states, apdu, apdu_size);
|
||||
apdu_len = bacnet_array_encode(
|
||||
rpdata->object_instance, rpdata->array_index,
|
||||
Multistate_Input_State_Text_Encode, max_states, apdu,
|
||||
apdu_size);
|
||||
if (apdu_len == BACNET_STATUS_ABORT) {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
@@ -775,7 +780,8 @@ int Multistate_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
}
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
characterstring_init_ansi(&char_string,
|
||||
characterstring_init_ansi(
|
||||
&char_string,
|
||||
Multistate_Input_Description(rpdata->object_instance));
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
@@ -832,10 +838,9 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
|
||||
if (status) {
|
||||
status =
|
||||
Multistate_Input_Present_Value_Write(wp_data->object_instance,
|
||||
value.type.Enumerated,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
status = Multistate_Input_Present_Value_Write(
|
||||
wp_data->object_instance, value.type.Enumerated,
|
||||
&wp_data->error_class, &wp_data->error_code);
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
@@ -848,10 +853,8 @@ bool Multistate_Input_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 {
|
||||
|
||||
Reference in New Issue
Block a user