Add and fix compiler warnings (#718)
* Add and remove compiler warning compile options
Add some new compiler warnings. Some of those does not build clean so
ignore them for now. This also helps if some user use those options so
we ignore those for them also.
Also remove following ignores as they do not produce any warnings:
- Wno-attributes
- Wno-long-long
- Wno-implicit-fallthrough
* Fix -Wmissing-declarations compiler warnings
Fix new -Wmissing-declarations compiler warnings. I tried to look which
should be in headers and which should be static. Might be that some
statics should be in header as it is not easy to choose if something
should be exported or not.
* Fix -Wmissing-field-initializers compiler warnings
If we use { { 0 } } compiler thinks we might have mean that we only
meant initialize first member of struct or have forgotton to add second
one. We could do { { 0 }, 0 } but we can just do { 0 } which tells
compiler that hey just intialize this whole thing to zero.
* tests: Fix couple -Wfloat-conversion warnings
Add f prefix to floating point numbers to get some double to float
warnings away.
* ci: Make warnings as errors with cmake main build
To keep repo more clean from warnings use Werror flag when building main
project.
Windows should need -DCMAKE_C_FLAGS="/WX" but we have not ignore errors
for that yet so let's not yet take it in use.
* ci: Build also tests in matrix build
Enable also tests to be builded in our main matrix build. This way tests
will be builded also with clang and in future also with MSVC. We also
keep build very clean now as all warnings as catched.
With this we can also take out -Werror from compile_options as we add
that in CI. It is not good practice to keep that option always on. It
makes development lot harder. See example this blog post [1].
[1]: https://embeddedartistry.com/blog/2017/05/22/werror-is-not-your-friend/
* getevent: Deprecate getevent_encode_apdu()
Steve suggested that we should deprecate getevent_encode_apdu() [1].
Suggested-by: Steve Karg
[1]: https://github.com/bacnet-stack/bacnet-stack/pull/718#discussion_r1715821735
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -493,7 +493,7 @@ static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
|
||||
*/
|
||||
int bip_get_local_address_ioctl(char *ifname, struct in_addr *addr, int request)
|
||||
{
|
||||
struct ifreq ifr = { { { 0 } }, { { 0 } } };
|
||||
struct ifreq ifr = { 0 };
|
||||
struct sockaddr_in *tcpip_address;
|
||||
int rv; /* return value */
|
||||
|
||||
|
||||
+1
-1
@@ -284,7 +284,7 @@ uint16_t bip6_receive(
|
||||
int max = 0;
|
||||
struct timeval select_timeout;
|
||||
struct sockaddr_in6 sin = { 0 };
|
||||
BACNET_IP6_ADDRESS addr = { { 0 } };
|
||||
BACNET_IP6_ADDRESS addr = { 0 };
|
||||
socklen_t sin_len = sizeof(sin);
|
||||
int received_bytes = 0;
|
||||
int offset = 0;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
if (x < 0xFFFF) \
|
||||
x++; \
|
||||
}
|
||||
uint32_t Timer_Silence(void *poPort)
|
||||
static uint32_t Timer_Silence(void *poPort)
|
||||
{
|
||||
struct timeval now, tmp_diff;
|
||||
SHARED_MSTP_DATA *poSharedData;
|
||||
@@ -62,7 +62,7 @@ uint32_t Timer_Silence(void *poPort)
|
||||
return (res >= 0 ? res : -res);
|
||||
}
|
||||
|
||||
void Timer_Silence_Reset(void *poPort)
|
||||
static void Timer_Silence_Reset(void *poPort)
|
||||
{
|
||||
SHARED_MSTP_DATA *poSharedData;
|
||||
struct mstp_port_struct_t *mstp_port = (struct mstp_port_struct_t *)poPort;
|
||||
@@ -77,7 +77,7 @@ void Timer_Silence_Reset(void *poPort)
|
||||
gettimeofday(&poSharedData->start, NULL);
|
||||
}
|
||||
|
||||
void get_abstime(struct timespec *abstime, unsigned long milliseconds)
|
||||
static void get_abstime(struct timespec *abstime, unsigned long milliseconds)
|
||||
{
|
||||
struct timeval now, offset, result;
|
||||
|
||||
@@ -196,7 +196,7 @@ uint16_t dlmstp_receive(
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
void *dlmstp_receive_fsm_task(void *pArg)
|
||||
static void *dlmstp_receive_fsm_task(void *pArg)
|
||||
{
|
||||
bool received_frame;
|
||||
SHARED_MSTP_DATA *poSharedData;
|
||||
@@ -231,7 +231,7 @@ void *dlmstp_receive_fsm_task(void *pArg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *dlmstp_master_fsm_task(void *pArg)
|
||||
static void *dlmstp_master_fsm_task(void *pArg)
|
||||
{
|
||||
uint32_t silence = 0;
|
||||
bool run_master = false;
|
||||
@@ -385,7 +385,7 @@ void MSTP_Send_Frame(
|
||||
RS485_Send_Frame(mstp_port, buffer, nbytes);
|
||||
}
|
||||
|
||||
bool dlmstp_compare_data_expecting_reply(
|
||||
static bool dlmstp_compare_data_expecting_reply(
|
||||
uint8_t *request_pdu,
|
||||
uint16_t request_pdu_len,
|
||||
uint8_t src_address,
|
||||
|
||||
Reference in New Issue
Block a user