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:
@@ -46,7 +46,8 @@
|
||||
* @param service_data [in] The BACNET_CONFIRMED_SERVICE_DATA information
|
||||
* decoded from the APDU header of this message.
|
||||
*/
|
||||
void handler_reinitialize_device(uint8_t *service_request,
|
||||
void handler_reinitialize_device(
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_CONFIRMED_SERVICE_DATA *service_data)
|
||||
@@ -66,9 +67,9 @@ void handler_reinitialize_device(uint8_t *service_request,
|
||||
fprintf(stderr, "ReinitializeDevice!\n");
|
||||
#endif
|
||||
if (service_data->segmented_message) {
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
||||
true);
|
||||
len = abort_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "ReinitializeDevice: Sending Abort - segmented message.\n");
|
||||
@@ -80,7 +81,8 @@ void handler_reinitialize_device(uint8_t *service_request,
|
||||
service_request, service_len, &rd_data.state, &rd_data.password);
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0) {
|
||||
fprintf(stderr, "ReinitializeDevice: state=%u password=%*s\n",
|
||||
fprintf(
|
||||
stderr, "ReinitializeDevice: state=%u password=%*s\n",
|
||||
(unsigned)rd_data.state,
|
||||
(int)characterstring_length(&rd_data.password),
|
||||
characterstring_value(&rd_data.password));
|
||||
@@ -90,8 +92,9 @@ void handler_reinitialize_device(uint8_t *service_request,
|
||||
#endif
|
||||
/* bad decoding or something we didn't understand - send an abort */
|
||||
if (len < 0) {
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER, true);
|
||||
len = abort_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
|
||||
ABORT_REASON_OTHER, true);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "ReinitializeDevice: Sending Abort - could not decode.\n");
|
||||
@@ -100,10 +103,12 @@ void handler_reinitialize_device(uint8_t *service_request,
|
||||
}
|
||||
/* check the data from the request */
|
||||
if (rd_data.state >= BACNET_REINIT_MAX) {
|
||||
len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, REJECT_REASON_UNDEFINED_ENUMERATION);
|
||||
len = reject_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
|
||||
REJECT_REASON_UNDEFINED_ENUMERATION);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"ReinitializeDevice: Sending Reject - undefined enumeration\n");
|
||||
#endif
|
||||
} else {
|
||||
@@ -112,20 +117,23 @@ void handler_reinitialize_device(uint8_t *service_request,
|
||||
len = Routed_Device_Service_Approval(
|
||||
SERVICE_SUPPORTED_REINITIALIZE_DEVICE, (int)rd_data.state,
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
|
||||
if (len > 0)
|
||||
if (len > 0) {
|
||||
goto RD_ABORT;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Device_Reinitialize(&rd_data)) {
|
||||
len = encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE);
|
||||
len = encode_simple_ack(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_REINITIALIZE_DEVICE);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "ReinitializeDevice: Sending Simple Ack!\n");
|
||||
#endif
|
||||
} else {
|
||||
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||
rd_data.error_class, rd_data.error_code);
|
||||
len = bacerror_encode_apdu(
|
||||
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, rd_data.error_class,
|
||||
rd_data.error_code);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "ReinitializeDevice: Sending Error.\n");
|
||||
#endif
|
||||
@@ -137,7 +145,8 @@ RD_ABORT:
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (len <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
|
||||
fprintf(
|
||||
stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user