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:
@@ -77,8 +77,8 @@
|
||||
|
||||
/* external prototypes */
|
||||
extern int Routed_Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata);
|
||||
extern bool Routed_Device_Write_Property_Local(
|
||||
BACNET_WRITE_PROPERTY_DATA *wp_data);
|
||||
extern bool
|
||||
Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data);
|
||||
|
||||
/* may be overridden by outside table */
|
||||
static object_functions_t *Object_Table;
|
||||
@@ -404,8 +404,8 @@ static object_functions_t My_Object_Table[] = {
|
||||
* @return Pointer to the group of object helper functions that implement this
|
||||
* type of Object.
|
||||
*/
|
||||
static struct object_functions *Device_Objects_Find_Functions(
|
||||
BACNET_OBJECT_TYPE Object_Type)
|
||||
static struct object_functions *
|
||||
Device_Objects_Find_Functions(BACNET_OBJECT_TYPE Object_Type)
|
||||
{
|
||||
struct object_functions *pObject = NULL;
|
||||
|
||||
@@ -451,7 +451,8 @@ rr_info_function Device_Objects_RR_Info(BACNET_OBJECT_TYPE object_type)
|
||||
* list, separately, the Required, Optional, and Proprietary object
|
||||
* properties with their counts.
|
||||
*/
|
||||
void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type,
|
||||
void Device_Objects_Property_List(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
struct special_property_list_t *pPropertyList)
|
||||
{
|
||||
@@ -469,8 +470,9 @@ void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type,
|
||||
|
||||
pObject = Device_Objects_Find_Functions(object_type);
|
||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||
pObject->Object_RPM_List(
|
||||
&pPropertyList->Required.pList, &pPropertyList->Optional.pList,
|
||||
&pPropertyList->Proprietary.pList);
|
||||
}
|
||||
|
||||
/* Fetch the counts if available otherwise zero them */
|
||||
@@ -559,8 +561,8 @@ bool Device_Objects_Property_List_Member(
|
||||
property_list_member(property_list.Optional.pList, object_property);
|
||||
}
|
||||
if (!found) {
|
||||
found = property_list_member(property_list.Proprietary.pList,
|
||||
object_property);
|
||||
found = property_list_member(
|
||||
property_list.Proprietary.pList, object_property);
|
||||
}
|
||||
|
||||
return found;
|
||||
@@ -1124,7 +1126,8 @@ int Device_Object_List_Element_Encode(
|
||||
* Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(
|
||||
const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
@@ -1143,7 +1146,7 @@ bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
pObject = Device_Objects_Find_Functions(type);
|
||||
if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
|
||||
(pObject->Object_Name(instance, &object_name2) &&
|
||||
characterstring_same(object_name1, &object_name2))) {
|
||||
characterstring_same(object_name1, &object_name2))) {
|
||||
found = true;
|
||||
if (object_type) {
|
||||
*object_type = type;
|
||||
@@ -1184,7 +1187,8 @@ bool Device_Valid_Object_Id(
|
||||
* @param object_name [out] The Object Name found for this child Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Object_Name_Copy(BACNET_OBJECT_TYPE object_type,
|
||||
bool Device_Object_Name_Copy(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
@@ -1402,7 +1406,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
bitstring_init(&bit_string);
|
||||
for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) {
|
||||
/* automatic lookup based on handlers set */
|
||||
bitstring_set_bit(&bit_string, (uint8_t)i,
|
||||
bitstring_set_bit(
|
||||
&bit_string, (uint8_t)i,
|
||||
apdu_service_supported((BACNET_SERVICES_SUPPORTED)i));
|
||||
}
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
@@ -1429,9 +1434,9 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
case PROP_OBJECT_LIST:
|
||||
count = Device_Object_List_Count();
|
||||
apdu_len = bacnet_array_encode(rpdata->object_instance,
|
||||
rpdata->array_index, Device_Object_List_Element_Encode, count,
|
||||
apdu, apdu_max);
|
||||
apdu_len = bacnet_array_encode(
|
||||
rpdata->object_instance, rpdata->array_index,
|
||||
Device_Object_List_Element_Encode, count, apdu, apdu_max);
|
||||
if (apdu_len == BACNET_STATUS_ABORT) {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
@@ -1554,8 +1559,9 @@ static int Read_Property_Common(
|
||||
} else if (rpdata->object_property == PROP_PROPERTY_LIST) {
|
||||
Device_Objects_Property_List(
|
||||
rpdata->object_type, rpdata->object_instance, &property_list);
|
||||
apdu_len = property_list_encode(rpdata, property_list.Required.pList,
|
||||
property_list.Optional.pList, property_list.Proprietary.pList);
|
||||
apdu_len = property_list_encode(
|
||||
rpdata, property_list.Required.pList, property_list.Optional.pList,
|
||||
property_list.Proprietary.pList);
|
||||
#endif
|
||||
} else if (pObject->Object_Read_Property) {
|
||||
apdu_len = pObject->Object_Read_Property(rpdata);
|
||||
@@ -1693,8 +1699,9 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data, &value, characterstring_capacity(&My_Object_Name));
|
||||
if (status) {
|
||||
/* All the object names in a device must be unique */
|
||||
if (Device_Valid_Object_Name(&value.type.Character_String,
|
||||
&object_type, &object_instance)) {
|
||||
if (Device_Valid_Object_Name(
|
||||
&value.type.Character_String, &object_type,
|
||||
&object_instance)) {
|
||||
if ((object_type == wp_data->object_type) &&
|
||||
(object_instance == wp_data->object_instance)) {
|
||||
/* writing same name to same object */
|
||||
@@ -1821,10 +1828,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
#endif
|
||||
default:
|
||||
if (property_lists_member(
|
||||
Device_Properties_Required,
|
||||
Device_Properties_Optional,
|
||||
Device_Properties_Proprietary,
|
||||
wp_data->object_property)) {
|
||||
Device_Properties_Required, Device_Properties_Optional,
|
||||
Device_Properties_Proprietary, wp_data->object_property)) {
|
||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
} else {
|
||||
@@ -1907,8 +1912,7 @@ static bool Device_Write_Property_Object_Name(
|
||||
* @brief Set the callback for a WriteProperty successful operation
|
||||
* @param cb [in] The function to be called, or NULL to disable
|
||||
*/
|
||||
void Device_Write_Property_Store_Callback_Set(
|
||||
write_property_function cb)
|
||||
void Device_Write_Property_Store_Callback_Set(write_property_function cb)
|
||||
{
|
||||
Device_Write_Property_Store_Callback = cb;
|
||||
}
|
||||
@@ -2053,7 +2057,8 @@ int Device_Remove_List_Element(BACNET_LIST_ELEMENT_DATA *list_element)
|
||||
* @param [out] The value list
|
||||
* @return True if the object instance supports this feature and value changed.
|
||||
*/
|
||||
bool Device_Encode_Value_List(BACNET_OBJECT_TYPE object_type,
|
||||
bool Device_Encode_Value_List(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_VALUE *value_list)
|
||||
{
|
||||
@@ -2138,7 +2143,8 @@ bool Device_Create_Object(BACNET_CREATE_OBJECT_DATA *data)
|
||||
object for some other reason.*/
|
||||
data->error_class = ERROR_CLASS_OBJECT;
|
||||
data->error_code = ERROR_CODE_DYNAMIC_CREATION_NOT_SUPPORTED;
|
||||
} else if (pObject->Object_Valid_Instance &&
|
||||
} else if (
|
||||
pObject->Object_Valid_Instance &&
|
||||
pObject->Object_Valid_Instance(data->object_instance)) {
|
||||
/* The object being created already exists */
|
||||
data->error_class = ERROR_CLASS_OBJECT;
|
||||
@@ -2196,7 +2202,8 @@ bool Device_Delete_Object(BACNET_DELETE_OBJECT_DATA *data)
|
||||
object for some reason.*/
|
||||
data->error_class = ERROR_CLASS_OBJECT;
|
||||
data->error_code = ERROR_CODE_OBJECT_DELETION_NOT_PERMITTED;
|
||||
} else if (pObject->Object_Valid_Instance &&
|
||||
} else if (
|
||||
pObject->Object_Valid_Instance &&
|
||||
pObject->Object_Valid_Instance(data->object_instance)) {
|
||||
/* The object being deleted must already exist */
|
||||
status = pObject->Object_Delete(data->object_instance);
|
||||
@@ -2299,7 +2306,8 @@ void Device_Init(object_functions_t *object_table)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DeviceGetRRInfo(BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||
bool DeviceGetRRInfo(
|
||||
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
||||
RR_PROP_INFO *pInfo)
|
||||
{ /* Where to put the response */
|
||||
bool status = false; /* return value */
|
||||
|
||||
Reference in New Issue
Block a user