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:
+51
-46
@@ -67,14 +67,16 @@ static BACNET_ADDRESS Target_Address;
|
||||
/* needed for return value of main application */
|
||||
static bool Error_Detected = false;
|
||||
|
||||
static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
static void MyErrorHandler(
|
||||
BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
BACNET_ERROR_CLASS error_class,
|
||||
BACNET_ERROR_CODE error_code)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Error: %s: %s\n",
|
||||
printf(
|
||||
"BACnet Error: %s: %s\n",
|
||||
bactext_error_class_name((int)error_class),
|
||||
bactext_error_code_name((int)error_code));
|
||||
Error_Detected = true;
|
||||
@@ -93,19 +95,20 @@ static void MyAbortHandler(
|
||||
}
|
||||
}
|
||||
|
||||
static void MyRejectHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
static void
|
||||
MyRejectHandler(BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Reject: %s\n",
|
||||
printf(
|
||||
"BACnet Reject: %s\n",
|
||||
bactext_reject_reason_name((int)reject_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void MyWritePropertySimpleAckHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
static void
|
||||
MyWritePropertySimpleAckHandler(BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
@@ -138,8 +141,9 @@ static void Init_Service_Handlers(void)
|
||||
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property priority index tag value [tag value...]\n",
|
||||
printf(
|
||||
"Usage: %s device-instance object-type object-instance "
|
||||
"property priority index tag value [tag value...]\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
@@ -152,14 +156,13 @@ static void print_help(const char *filename)
|
||||
"the device using Who-Is and I-Am services. For example, if you were\n"
|
||||
"writing to Device Object 123, the device-instance would be 123.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-type:\n"
|
||||
"The object type is object that you are writing. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were writing Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are writing. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were writing Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"object-instance:\n"
|
||||
@@ -167,22 +170,20 @@ static void print_help(const char *filename)
|
||||
"writing to. For example, if you were writing to Analog Output 2, \n"
|
||||
"the object-instance would be 2.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"property:\n"
|
||||
"The property of the object that you are writing. It\n"
|
||||
"can be defined either as the property name string as\n"
|
||||
"defined in the BACnet specification, or as an integer\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||
"bacenum.h. For example, if you were writing the Present\n"
|
||||
"Value property, use present-value or 85 as the property.\n");
|
||||
printf("property:\n"
|
||||
"The property of the object that you are writing. It\n"
|
||||
"can be defined either as the property name string as\n"
|
||||
"defined in the BACnet specification, or as an integer\n"
|
||||
"value of the enumeration BACNET_PROPERTY_ID in\n"
|
||||
"bacenum.h. For example, if you were writing the Present\n"
|
||||
"Value property, use present-value or 85 as the property.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"priority:\n"
|
||||
"This parameter is used for setting the priority of the\n"
|
||||
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||
"standard states that the value is written at the lowest \n"
|
||||
"priority (16) if the object property supports priorities\n"
|
||||
"when no priority is sent.\n");
|
||||
printf("priority:\n"
|
||||
"This parameter is used for setting the priority of the\n"
|
||||
"write. If Priority 0 is given, no priority is sent. The BACnet \n"
|
||||
"standard states that the value is written at the lowest \n"
|
||||
"priority (16) if the object property supports priorities\n"
|
||||
"when no priority is sent.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"index\n"
|
||||
@@ -199,10 +200,9 @@ static void print_help(const char *filename)
|
||||
"Context tags are created using two tags in a row. The context tag\n"
|
||||
"is preceded by a C, and followed by the application tag.\n"
|
||||
"Ctag atag. C2 4 creates a context 2 tagged REAL.\n");
|
||||
printf(
|
||||
"Complex data use the property argument and a tag number -1 to\n"
|
||||
"lookup the appropriate internal application tag for the value.\n"
|
||||
"The complex data value argument varies in its construction.\n");
|
||||
printf("Complex data use the property argument and a tag number -1 to\n"
|
||||
"lookup the appropriate internal application tag for the value.\n"
|
||||
"The complex data value argument varies in its construction.\n");
|
||||
printf("\n");
|
||||
printf(
|
||||
"value:\n"
|
||||
@@ -283,8 +283,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Target_Object_Property = object_property;
|
||||
priority = strtol(argv[5], NULL, 0);
|
||||
if ((priority < BACNET_MIN_PRIORITY) ||
|
||||
(priority > BACNET_MAX_PRIORITY)) {
|
||||
if ((priority < BACNET_MIN_PRIORITY) || (priority > BACNET_MAX_PRIORITY)) {
|
||||
priority = BACNET_NO_PRIORITY;
|
||||
}
|
||||
Target_Object_Property_Priority = priority;
|
||||
@@ -293,22 +292,26 @@ int main(int argc, char *argv[])
|
||||
Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
||||
}
|
||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - not greater than %u\n",
|
||||
fprintf(
|
||||
stderr, "device-instance=%u - not greater than %u\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
if (Target_Object_Type > MAX_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\n",
|
||||
fprintf(
|
||||
stderr, "object-type=%u - it must be less than %u\n",
|
||||
Target_Object_Type, MAX_BACNET_OBJECT_TYPE + 1);
|
||||
return 1;
|
||||
}
|
||||
if (Target_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "object-instance=%u - not greater than %u\n",
|
||||
fprintf(
|
||||
stderr, "object-instance=%u - not greater than %u\n",
|
||||
Target_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
if (Target_Object_Property > MAX_BACNET_PROPERTY_ID) {
|
||||
fprintf(stderr, "property=%u - it must be less than %u\n",
|
||||
fprintf(
|
||||
stderr, "property=%u - it must be less than %u\n",
|
||||
Target_Object_Property, MAX_BACNET_PROPERTY_ID + 1);
|
||||
return 1;
|
||||
}
|
||||
@@ -340,7 +343,8 @@ int main(int argc, char *argv[])
|
||||
property_tag = bacapp_known_property_tag(
|
||||
Target_Object_Type, Target_Object_Property);
|
||||
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
|
||||
fprintf(stderr, "Error: tag=%ld - it must be less than %u\n",
|
||||
fprintf(
|
||||
stderr, "Error: tag=%ld - it must be less than %u\n",
|
||||
property_tag, MAX_BACNET_APPLICATION_TAG);
|
||||
return 1;
|
||||
}
|
||||
@@ -353,8 +357,8 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Error: parser for property %s is not implemented\n",
|
||||
fprintf(
|
||||
stderr, "Error: parser for property %s is not implemented\n",
|
||||
bactext_property_name(Target_Object_Property));
|
||||
return 1;
|
||||
}
|
||||
@@ -387,7 +391,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
if (args_remaining > 0) {
|
||||
fprintf(stderr, "Error: Exceeded %d tag-value pairs.\n",
|
||||
fprintf(
|
||||
stderr, "Error: Exceeded %d tag-value pairs.\n",
|
||||
MAX_PROPERTY_VALUES);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user