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:
@@ -24,7 +24,8 @@
|
||||
*
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_context_device_obj_property_ref(uint8_t *apdu,
|
||||
int bacapp_encode_context_device_obj_property_ref(
|
||||
uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
const BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
@@ -78,7 +79,8 @@ int bacapp_encode_device_obj_property_ref(
|
||||
return apdu_len;
|
||||
}
|
||||
/* object-identifier [0] BACnetObjectIdentifier */
|
||||
len = encode_context_object_id(apdu, 0, value->objectIdentifier.type,
|
||||
len = encode_context_object_id(
|
||||
apdu, 0, value->objectIdentifier.type,
|
||||
value->objectIdentifier.instance);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
@@ -104,7 +106,8 @@ int bacapp_encode_device_obj_property_ref(
|
||||
* (set type to BACNET_NO_DEV_TYPE or something other than OBJECT_DEVICE to
|
||||
* omit */
|
||||
if (value->deviceIdentifier.type == OBJECT_DEVICE) {
|
||||
len = encode_context_object_id(apdu, 3, value->deviceIdentifier.type,
|
||||
len = encode_context_object_id(
|
||||
apdu, 3, value->deviceIdentifier.type,
|
||||
value->deviceIdentifier.instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
@@ -131,7 +134,8 @@ int bacapp_encode_device_obj_property_ref(
|
||||
*
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacnet_device_object_property_reference_decode(const uint8_t *apdu,
|
||||
int bacnet_device_object_property_reference_decode(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
@@ -147,8 +151,9 @@ int bacnet_device_object_property_reference_decode(const uint8_t *apdu,
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* object-identifier [0] BACnetObjectIdentifier */
|
||||
len = bacnet_object_id_context_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
0, &object_type, &object_instance);
|
||||
len = bacnet_object_id_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 0, &object_type,
|
||||
&object_instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
@@ -173,8 +178,9 @@ int bacnet_device_object_property_reference_decode(const uint8_t *apdu,
|
||||
if (bacnet_is_context_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 2, &len, &len_value_type)) {
|
||||
apdu_len += len;
|
||||
len = bacnet_unsigned_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
len_value_type, &array_index);
|
||||
len = bacnet_unsigned_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, len_value_type,
|
||||
&array_index);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
@@ -193,8 +199,9 @@ int bacnet_device_object_property_reference_decode(const uint8_t *apdu,
|
||||
if (bacnet_is_context_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 3, &len, &len_value_type)) {
|
||||
apdu_len += len;
|
||||
len = bacnet_object_id_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
len_value_type, &object_type, &object_instance);
|
||||
len = bacnet_object_id_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, len_value_type, &object_type,
|
||||
&object_instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
@@ -226,7 +233,8 @@ int bacnet_device_object_property_reference_decode(const uint8_t *apdu,
|
||||
*
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacnet_device_object_property_reference_context_decode(const uint8_t *apdu,
|
||||
int bacnet_device_object_property_reference_context_decode(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
@@ -275,10 +283,10 @@ bool bacnet_device_object_property_reference_same(
|
||||
if (value1 && value2) {
|
||||
if ((value1->arrayIndex == value2->arrayIndex) &&
|
||||
(value1->deviceIdentifier.instance ==
|
||||
value2->deviceIdentifier.instance) &&
|
||||
value2->deviceIdentifier.instance) &&
|
||||
(value1->deviceIdentifier.type == value2->deviceIdentifier.type) &&
|
||||
(value1->objectIdentifier.instance ==
|
||||
value2->objectIdentifier.instance) &&
|
||||
value2->objectIdentifier.instance) &&
|
||||
(value1->objectIdentifier.type == value2->objectIdentifier.type) &&
|
||||
(value1->propertyIdentifier == value2->propertyIdentifier)) {
|
||||
status = true;
|
||||
@@ -328,7 +336,8 @@ int bacapp_decode_device_obj_property_ref(
|
||||
* @deprecated Use bacnet_device_object_property_reference_context_decode()
|
||||
* instead
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_property_ref(const uint8_t *apdu,
|
||||
int bacapp_decode_context_device_obj_property_ref(
|
||||
const uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE *value)
|
||||
{
|
||||
@@ -352,7 +361,9 @@ int bacapp_decode_context_device_obj_property_ref(const uint8_t *apdu,
|
||||
* @return Bytes encoded or 0 on failure.
|
||||
*/
|
||||
int bacapp_encode_context_device_obj_ref(
|
||||
uint8_t *apdu, uint8_t tag_number, const BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
const BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -400,15 +411,17 @@ int bacapp_encode_device_obj_ref(
|
||||
set type to BACNET_NO_DEV_TYPE or something other
|
||||
than OBJECT_DEVICE to omit */
|
||||
if (value->deviceIdentifier.type == OBJECT_DEVICE) {
|
||||
len = encode_context_object_id(apdu, 0,
|
||||
value->deviceIdentifier.type, value->deviceIdentifier.instance);
|
||||
len = encode_context_object_id(
|
||||
apdu, 0, value->deviceIdentifier.type,
|
||||
value->deviceIdentifier.instance);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
apdu += len;
|
||||
}
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len = encode_context_object_id(apdu, 1, value->objectIdentifier.type,
|
||||
len = encode_context_object_id(
|
||||
apdu, 1, value->objectIdentifier.type,
|
||||
value->objectIdentifier.instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
@@ -431,7 +444,9 @@ int bacapp_encode_device_obj_ref(
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacnet_device_object_reference_decode(
|
||||
const uint8_t *apdu, uint32_t apdu_size, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
@@ -446,8 +461,9 @@ int bacnet_device_object_reference_decode(
|
||||
if (bacnet_is_context_tag_number(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 0, &len, &len_value_type)) {
|
||||
apdu_len += len;
|
||||
len = bacnet_object_id_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
len_value_type, &object_type, &object_instance);
|
||||
len = bacnet_object_id_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, len_value_type, &object_type,
|
||||
&object_instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
@@ -463,8 +479,9 @@ int bacnet_device_object_reference_decode(
|
||||
value->deviceIdentifier.instance = BACNET_NO_DEV_ID;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
len = bacnet_object_id_context_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
1, &object_type, &object_instance);
|
||||
len = bacnet_object_id_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 1, &object_type,
|
||||
&object_instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
if (value) {
|
||||
@@ -489,7 +506,8 @@ int bacnet_device_object_reference_decode(
|
||||
*
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacnet_device_object_reference_context_decode(const uint8_t *apdu,
|
||||
int bacnet_device_object_reference_context_decode(
|
||||
const uint8_t *apdu,
|
||||
uint32_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
@@ -537,10 +555,10 @@ bool bacnet_device_object_reference_same(
|
||||
|
||||
if (value1 && value2) {
|
||||
if ((value1->deviceIdentifier.instance ==
|
||||
value2->deviceIdentifier.instance) &&
|
||||
value2->deviceIdentifier.instance) &&
|
||||
(value1->deviceIdentifier.type == value2->deviceIdentifier.type) &&
|
||||
(value1->objectIdentifier.instance ==
|
||||
value2->objectIdentifier.instance) &&
|
||||
value2->objectIdentifier.instance) &&
|
||||
(value1->objectIdentifier.type == value2->objectIdentifier.type)) {
|
||||
status = true;
|
||||
}
|
||||
@@ -583,7 +601,9 @@ int bacapp_decode_device_obj_ref(
|
||||
* @deprecated Use bacnet_device_object_reference_context_decode() instead.
|
||||
*/
|
||||
int bacapp_decode_context_device_obj_ref(
|
||||
const uint8_t *apdu, uint8_t tag_number, BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
const uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_DEVICE_OBJECT_REFERENCE *value)
|
||||
{
|
||||
return bacnet_device_object_reference_context_decode(
|
||||
apdu, MAX_APDU, tag_number, value);
|
||||
@@ -616,7 +636,8 @@ int bacapp_encode_obj_property_ref(
|
||||
if (reference->object_identifier.type == OBJECT_NONE) {
|
||||
return 0;
|
||||
}
|
||||
len = encode_context_object_id(apdu, 0, reference->object_identifier.type,
|
||||
len = encode_context_object_id(
|
||||
apdu, 0, reference->object_identifier.type,
|
||||
reference->object_identifier.instance);
|
||||
apdu_len += len;
|
||||
if (apdu) {
|
||||
@@ -642,7 +663,8 @@ int bacapp_encode_obj_property_ref(
|
||||
* @param reference - BACnetObjectPropertyReference to encode
|
||||
* @return length of the APDU buffer
|
||||
*/
|
||||
int bacapp_encode_context_obj_property_ref(uint8_t *apdu,
|
||||
int bacapp_encode_context_obj_property_ref(
|
||||
uint8_t *apdu,
|
||||
uint8_t tag_number,
|
||||
const BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
{
|
||||
@@ -684,7 +706,8 @@ int bacapp_encode_context_obj_property_ref(uint8_t *apdu,
|
||||
* @param reference - BACnetObjectPropertyReference to decode into
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_obj_property_ref(const uint8_t *apdu,
|
||||
int bacapp_decode_obj_property_ref(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *reference)
|
||||
{
|
||||
@@ -698,8 +721,9 @@ int bacapp_decode_obj_property_ref(const uint8_t *apdu,
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* object-identifier [0] BACnetObjectIdentifier */
|
||||
len = bacnet_object_id_context_decode(&apdu[apdu_len], apdu_size - apdu_len,
|
||||
0, &object_identifier.type, &object_identifier.instance);
|
||||
len = bacnet_object_id_context_decode(
|
||||
&apdu[apdu_len], apdu_size - apdu_len, 0, &object_identifier.type,
|
||||
&object_identifier.instance);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else if (len <= 0) {
|
||||
@@ -756,7 +780,8 @@ int bacapp_decode_obj_property_ref(const uint8_t *apdu,
|
||||
*
|
||||
* @return number of bytes decoded or BACNET_STATUS_ERROR on failure.
|
||||
*/
|
||||
int bacapp_decode_context_obj_property_ref(const uint8_t *apdu,
|
||||
int bacapp_decode_context_obj_property_ref(
|
||||
const uint8_t *apdu,
|
||||
uint16_t apdu_size,
|
||||
uint8_t tag_number,
|
||||
BACNET_OBJECT_PROPERTY_REFERENCE *value)
|
||||
@@ -804,9 +829,9 @@ bool bacnet_object_property_reference_same(
|
||||
if (value1 && value2) {
|
||||
if ((value1->property_identifier == value2->property_identifier) &&
|
||||
(value1->object_identifier.instance ==
|
||||
value2->object_identifier.instance) &&
|
||||
value2->object_identifier.instance) &&
|
||||
(value1->object_identifier.type ==
|
||||
value2->object_identifier.type)) {
|
||||
value2->object_identifier.type)) {
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user