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
+13 -10
View File
@@ -137,8 +137,9 @@ void RS485_Print_Error(void)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf, 0, NULL);
MessageBox(NULL, lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);
@@ -237,8 +238,8 @@ static void RS485_Cleanup(void)
*****************************************************************************/
void RS485_Initialize(void)
{
RS485_Handle = CreateFile(RS485_Port_Name, GENERIC_READ | GENERIC_WRITE, 0,
0, OPEN_EXISTING,
RS485_Handle = CreateFile(
RS485_Port_Name, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
/*FILE_FLAG_OVERLAPPED */ 0, 0);
if (RS485_Handle == INVALID_HANDLE_VALUE) {
fprintf(stderr, "RS485 unable to open %s\n", RS485_Port_Name);
@@ -397,7 +398,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
/* Transmits a Frame on the wire */
void RS485_Send_Frame(
struct mstp_port_struct_t *mstp_port, /* port specific data */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
DWORD dwWritten = 0;
@@ -407,12 +408,13 @@ void RS485_Send_Frame(
uint8_t turnaround_time;
baud = RS485_Get_Baud_Rate();
/* wait about 40 bit times since reception */
if (baud == 9600)
if (baud == 9600) {
turnaround_time = 4;
else if (baud == 19200)
} else if (baud == 19200) {
turnaround_time = 2;
else
} else {
turnaround_time = 2;
}
while (mstp_port->SilenceTimer(NULL) < turnaround_time) {
/* do nothing - wait for timer to increment */
};
@@ -465,8 +467,9 @@ void RS485_Print_Ports(void)
for (i = 1; i < 256; i++) {
if (RS485_Interface_Valid(i)) {
/* note: format for Wireshark ExtCap */
printf("interface {value=COM%u}"
"{display=BACnet MS/TP on COM%u}\n",
printf(
"interface {value=COM%u}"
"{display=BACnet MS/TP on COM%u}\n",
i, i);
}
}