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:
@@ -144,7 +144,7 @@ static struct Address_Cache_Entry *address_remove_oldest(void)
|
||||
for (index = Top_Protected_Entry; index < MAX_ADDRESS_CACHE; index++) {
|
||||
pMatch = &Address_Cache[index];
|
||||
if ((pMatch->Flags &
|
||||
(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) ==
|
||||
(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) ==
|
||||
BAC_ADDR_IN_USE) {
|
||||
if (pMatch->TimeToLive <= ulTime) {
|
||||
/* Shorter lived entry found */
|
||||
@@ -166,7 +166,7 @@ static struct Address_Cache_Entry *address_remove_oldest(void)
|
||||
for (index = 0; index < MAX_ADDRESS_CACHE; index++) {
|
||||
pMatch = &Address_Cache[index];
|
||||
if ((pMatch->Flags &
|
||||
(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) ==
|
||||
(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ | BAC_ADDR_STATIC)) ==
|
||||
((uint8_t)(BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
|
||||
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
|
||||
ulTime = pMatch->TimeToLive;
|
||||
@@ -211,7 +211,8 @@ static void address_file_init(const char *pFilename)
|
||||
while (fgets(line, (int)sizeof(line), pFile) != NULL) {
|
||||
/* ignore comments */
|
||||
if (line[0] != ';') {
|
||||
if (sscanf(line, "%7ld %79s %5u %79s %4u", &device_id,
|
||||
if (sscanf(
|
||||
line, "%7ld %79s %5u %79s %4u", &device_id,
|
||||
&mac_string[0], &snet, &sadr_string[0],
|
||||
&max_apdu) == 5) {
|
||||
if (bacnet_address_mac_from_ascii(&mac, mac_string)) {
|
||||
@@ -503,7 +504,8 @@ void address_add(
|
||||
*
|
||||
* @return true if device is already bound
|
||||
*/
|
||||
bool address_device_bind_request(uint32_t device_id,
|
||||
bool address_device_bind_request(
|
||||
uint32_t device_id,
|
||||
uint32_t *device_ttl,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS *src)
|
||||
@@ -633,7 +635,8 @@ void address_add_binding(
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
bool address_device_get_by_index(unsigned index,
|
||||
bool address_device_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t *device_id,
|
||||
uint32_t *device_ttl,
|
||||
unsigned *max_apdu,
|
||||
@@ -676,7 +679,8 @@ bool address_device_get_by_index(unsigned index,
|
||||
*
|
||||
* @return true/false
|
||||
*/
|
||||
bool address_get_by_index(unsigned index,
|
||||
bool address_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t *device_id,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS *src)
|
||||
@@ -880,7 +884,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pMatch = Address_Cache;
|
||||
uiIndex = 1;
|
||||
while ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) !=
|
||||
BAC_ADDR_IN_USE) { /* Find first bound entry */
|
||||
BAC_ADDR_IN_USE) { /* Find first bound entry */
|
||||
pMatch++;
|
||||
/* Shall not happen as the count has been checked first. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
@@ -947,7 +951,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pRequest->ItemCount++;
|
||||
|
||||
while ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) !=
|
||||
BAC_ADDR_IN_USE) {
|
||||
BAC_ADDR_IN_USE) {
|
||||
/* Find next bound entry */
|
||||
pMatch++;
|
||||
/* Can normally not happen. */
|
||||
@@ -987,8 +991,8 @@ void address_cache_timer(uint16_t uSeconds)
|
||||
pMatch = &Address_Cache[index];
|
||||
if (((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_RESERVED)) != 0) &&
|
||||
((pMatch->Flags & BAC_ADDR_STATIC) ==
|
||||
0)) { /* Check all entries holding a slot except statics
|
||||
*/
|
||||
0)) { /* Check all entries holding a slot except statics
|
||||
*/
|
||||
if (pMatch->TimeToLive >= uSeconds) {
|
||||
pMatch->TimeToLive -= uSeconds;
|
||||
} else {
|
||||
|
||||
@@ -18,105 +18,84 @@
|
||||
#include "bacnet/readrange.h"
|
||||
|
||||
/* refactored utility functions - see bacaddr.c module */
|
||||
#define address_mac_init(m,a,l) bacnet_address_mac_init(m,a,l)
|
||||
#define address_mac_from_ascii(m,a) bacnet_address_mac_from_ascii(m,a)
|
||||
#define address_match(d,s) bacnet_address_same(d,s)
|
||||
#define address_mac_init(m, a, l) bacnet_address_mac_init(m, a, l)
|
||||
#define address_mac_from_ascii(m, a) bacnet_address_mac_from_ascii(m, a)
|
||||
#define address_match(d, s) bacnet_address_same(d, s)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_init(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_init(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_init_partial(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_init_partial(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_add(
|
||||
uint32_t device_id,
|
||||
unsigned max_apdu,
|
||||
const BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_add(
|
||||
uint32_t device_id, unsigned max_apdu, const BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_remove_device(
|
||||
uint32_t device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_remove_device(uint32_t device_id);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_by_device(
|
||||
uint32_t device_id,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_by_device(
|
||||
uint32_t device_id, unsigned *max_apdu, BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t * device_id,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t *device_id,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_device_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t * device_id,
|
||||
uint32_t * device_ttl,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_device_get_by_index(
|
||||
unsigned index,
|
||||
uint32_t *device_id,
|
||||
uint32_t *device_ttl,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_device_id(
|
||||
const BACNET_ADDRESS * src,
|
||||
uint32_t * device_id);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_get_device_id(const BACNET_ADDRESS *src, uint32_t *device_id);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned address_count(
|
||||
void);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned address_count(void);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_bind_request(
|
||||
uint32_t device_id,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_bind_request(
|
||||
uint32_t device_id, unsigned *max_apdu, BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_device_bind_request(
|
||||
uint32_t device_id,
|
||||
uint32_t * device_ttl,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
bool address_device_bind_request(
|
||||
uint32_t device_id,
|
||||
uint32_t *device_ttl,
|
||||
unsigned *max_apdu,
|
||||
BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_add_binding(
|
||||
uint32_t device_id,
|
||||
unsigned max_apdu,
|
||||
const BACNET_ADDRESS * src);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_add_binding(
|
||||
uint32_t device_id, unsigned max_apdu, const BACNET_ADDRESS *src);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int address_list_encode(
|
||||
uint8_t * apdu,
|
||||
unsigned apdu_len);
|
||||
BACNET_STACK_EXPORT
|
||||
int address_list_encode(uint8_t *apdu, unsigned apdu_len);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
int rr_address_list_encode(
|
||||
uint8_t * apdu,
|
||||
BACNET_READ_RANGE_DATA * pRequest);
|
||||
BACNET_STACK_EXPORT
|
||||
int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_set_device_TTL(
|
||||
uint32_t device_id,
|
||||
uint32_t TimeOut,
|
||||
bool StaticFlag);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_set_device_TTL(
|
||||
uint32_t device_id, uint32_t TimeOut, bool StaticFlag);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_cache_timer(
|
||||
uint16_t uSeconds);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_cache_timer(uint16_t uSeconds);
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
void address_protected_entry_index_set(uint32_t top_protected_entry_index);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_own_device_id_set(uint32_t own_id);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_protected_entry_index_set(uint32_t top_protected_entry_index);
|
||||
BACNET_STACK_EXPORT
|
||||
void address_own_device_id_set(uint32_t own_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user