Make clean build with MSVC /Wall (#740)
* ci: Fix compile warning as errors was not correct
We want to enable warning as errors both Windows and Linux. This is
easiest to do with cmake option as -Werror does not work with MSVC. Also
it is self explaining what it does so no comment needed.
* dlmstp_linux: Fix -Wdeclaration-after-statement compiler warnings
Make dlmstp_linux C89/C90 combatible
```
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘Timer_Silence’:
/bacnet-stack/ports/linux/dlmstp_linux.c:56:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
56 | int32_t res;
| ^~~~~~~
/bacnet-stack/ports/linux/dlmstp_linux.c: In function ‘dlmstp_init’:
/bacnet-stack/ports/linux/dlmstp_linux.c:795:5: warning:
ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
795 | struct termios newtio;
| ^~~~~~
```
* Fix warnings produces by MSVC
Now that we have enabled /Wall for MSVC we get some warnings with it
which can be easily fixed.
We get following warnings:
```
src\bacnet\bacstr.c(223,39): warning C4127: conditional expression is constant
apps\router-mstp\main.c(1123,1): warning C4702: unreachable code
apps\epics\main.c(885,53): warning C4459: declaration of 'myState' hides global declaration
```
* cmake: Use /Wall with MSVC
Make MSVC to build cleanly with Wall. This might matter for some Windows
developers. And you never know if MSVC will find more bugs.
* cmake: Improve router build
Router build gives some warnings as it is not C90 compatible. It is ok
that example is not following C90 rules. Also it is annoing to new user
to build this cmake as first error usually is that libconfig is not
found. Let's just give warning about this so first build will usually go
smoother.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
+7
-7
@@ -876,13 +876,13 @@ static uint8_t Read_Properties(
|
||||
* If the present state is GET_HEADING_RESPONSE, store the results
|
||||
* in globals for later use.
|
||||
* @param rpm_data [in] The list of RPM data received.
|
||||
* @param myState [in] The current state.
|
||||
* @param state [in] The current state.
|
||||
* @return The next state of the EPICS state machine, normally NEXT_OBJECT
|
||||
* if the RPM got good data, or GET_PROPERTY_REQUEST if we have to
|
||||
* singly process the list of Properties.
|
||||
*/
|
||||
static EPICS_STATES ProcessRPMData(
|
||||
BACNET_READ_ACCESS_DATA *rpm_data, EPICS_STATES myState)
|
||||
BACNET_READ_ACCESS_DATA *rpm_data, EPICS_STATES state)
|
||||
{
|
||||
BACNET_READ_ACCESS_DATA *old_rpm_data;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||
@@ -890,7 +890,7 @@ static EPICS_STATES ProcessRPMData(
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
BACNET_APPLICATION_DATA_VALUE *old_value;
|
||||
bool bSuccess = true;
|
||||
EPICS_STATES nextState = myState; /* assume no change */
|
||||
EPICS_STATES nextState = state; /* assume no change */
|
||||
/* Some flags to keep the output "pretty" -
|
||||
* wait and put these object lists at the end */
|
||||
bool bHasObjectList = false;
|
||||
@@ -902,7 +902,7 @@ static EPICS_STATES ProcessRPMData(
|
||||
while (rpm_property) {
|
||||
/* For the GET_LIST_OF_ALL_RESPONSE case,
|
||||
* just keep what property this was */
|
||||
if (myState == GET_LIST_OF_ALL_RESPONSE) {
|
||||
if (state == GET_LIST_OF_ALL_RESPONSE) {
|
||||
switch (rpm_property->propertyIdentifier) {
|
||||
case PROP_OBJECT_LIST:
|
||||
bHasObjectList = true; /* Will append below */
|
||||
@@ -924,7 +924,7 @@ static EPICS_STATES ProcessRPMData(
|
||||
value = value->next;
|
||||
free(old_value);
|
||||
}
|
||||
} else if (myState == GET_HEADING_RESPONSE) {
|
||||
} else if (state == GET_HEADING_RESPONSE) {
|
||||
Property_Value_List[i++].value = rpm_property->value;
|
||||
/* copy this pointer.
|
||||
* On error, the pointer will be null
|
||||
@@ -946,10 +946,10 @@ static EPICS_STATES ProcessRPMData(
|
||||
}
|
||||
|
||||
/* Now determine the next state */
|
||||
if (myState == GET_HEADING_RESPONSE) {
|
||||
if (state == GET_HEADING_RESPONSE) {
|
||||
nextState = PRINT_HEADING;
|
||||
/* press ahead with or without the data */
|
||||
} else if (bSuccess && (myState == GET_ALL_RESPONSE)) {
|
||||
} else if (bSuccess && (state == GET_ALL_RESPONSE)) {
|
||||
nextState = NEXT_OBJECT;
|
||||
} else if (bSuccess) { /* and GET_LIST_OF_ALL_RESPONSE */
|
||||
/* Now append the properties we waited on. */
|
||||
|
||||
Reference in New Issue
Block a user