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
+10 -11
View File
@@ -1,10 +1,10 @@
/**************************************************************************
*
* Copyright (C) 2020 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
*
* Copyright (C) 2020 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
#ifndef BACPORT_H
#define BACPORT_H
@@ -19,11 +19,10 @@
#include "lwip/dhcp.h"
#include "lwip/inet.h"
#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \
_index_to_instance, _valid_instance, _object_name, \
_read_property, _write_property, _RPM_list, \
_RR_info, _iterator, _value_list, _COV, \
_COV_clear, _intrinsic_reporting) \
#define BACNET_OBJECT_TABLE( \
table_name, _type, _init, _count, _index_to_instance, _valid_instance, \
_object_name, _read_property, _write_property, _RPM_list, _RR_info, \
_iterator, _value_list, _COV, _COV_clear, _intrinsic_reporting) \
static_assert(false, "Unsupported BACNET_OBJECT_TABLE for this platform")
#endif
+9 -9
View File
@@ -153,9 +153,8 @@ static void bip_mac_to_addr(ip4_addr_t *address, const uint8_t *mac)
* @param address - IPv4 address from LwIP
* @param port - IPv4 UDP port number
*/
static int bip_decode_bip_address(const BACNET_IP_ADDRESS *baddr,
ip_addr_t *address,
uint16_t *port)
static int bip_decode_bip_address(
const BACNET_IP_ADDRESS *baddr, ip_addr_t *address, uint16_t *port)
{
int len = 0;
@@ -190,9 +189,8 @@ static void bip_addr_to_mac(uint8_t *mac, const ip4_addr_t *address)
* @param address - IPv4 address from LwIP
* @param port - IPv4 UDP port number
*/
static int bip_encode_bip_address(BACNET_IP_ADDRESS *baddr,
const ip_addr_t *address,
uint16_t port)
static int bip_encode_bip_address(
BACNET_IP_ADDRESS *baddr, const ip_addr_t *address, uint16_t port)
{
int len = 0;
@@ -249,7 +247,8 @@ int bip_send_mpdu(
*
* @return number of bytes sent
*/
int bip_send_pdu(BACNET_ADDRESS *dest, /* destination address */
int bip_send_pdu(
BACNET_ADDRESS *dest, /* destination address */
BACNET_NPDU_DATA *npdu_data, /* network information */
uint8_t *pdu, /* any data to be sent - may be null */
unsigned pdu_len)
@@ -265,7 +264,8 @@ int bip_send_pdu(BACNET_ADDRESS *dest, /* destination address */
* @param addr [in] UDP source address
* @param port [in] UDP port number
*/
void bip_server_callback(void *arg,
void bip_server_callback(
void *arg,
struct udp_pcb *upcb,
struct pbuf *pkt,
const ip_addr_t *addr,
@@ -275,7 +275,7 @@ void bip_server_callback(void *arg,
uint16_t npdu_offset = 0;
BACNET_ADDRESS src = { 0 }; /* address where message came from */
BACNET_IP_ADDRESS saddr;
uint8_t *npdu = (uint8_t *) pkt->payload;
uint8_t *npdu = (uint8_t *)pkt->payload;
uint16_t npdu_len = pkt->tot_len;
bip_encode_bip_address(&saddr, addr, port);
+6 -6
View File
@@ -1,10 +1,10 @@
/**************************************************************************
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
*
* Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
*
* SPDX-License-Identifier: MIT
*
*********************************************************************/
#ifndef NET_H
#define NET_H