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:
@@ -42,6 +42,7 @@
|
||||
}
|
||||
static uint32_t Timer_Silence(void *poPort)
|
||||
{
|
||||
int32_t res;
|
||||
struct timeval now, tmp_diff;
|
||||
SHARED_MSTP_DATA *poSharedData;
|
||||
struct mstp_port_struct_t *mstp_port = (struct mstp_port_struct_t *)poPort;
|
||||
@@ -53,8 +54,6 @@ static uint32_t Timer_Silence(void *poPort)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t res;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
timersub(&poSharedData->start, &now, &tmp_diff);
|
||||
res = ((tmp_diff.tv_sec) * 1000 + (tmp_diff.tv_usec) / 1000);
|
||||
@@ -764,6 +763,7 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
unsigned long hThread = 0;
|
||||
int rv = 0;
|
||||
SHARED_MSTP_DATA *poSharedData;
|
||||
struct termios newtio;
|
||||
struct mstp_port_struct_t *mstp_port = (struct mstp_port_struct_t *)poPort;
|
||||
if (!mstp_port) {
|
||||
return false;
|
||||
@@ -792,7 +792,6 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct termios newtio;
|
||||
printf("RS485: Initializing %s", poSharedData->RS485_Port_Name);
|
||||
/*
|
||||
Open device for reading and writing.
|
||||
|
||||
Reference in New Issue
Block a user