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:
Kari Argillander
2024-08-14 00:32:44 +03:00
committed by GitHub
parent cb243c36a8
commit 6271632944
33 changed files with 170 additions and 61 deletions
+19
View File
@@ -76,6 +76,12 @@ Structured_View_Subordinate_List(uint32_t object_instance);
BACNET_STACK_EXPORT
void Structured_View_Subordinate_List_Set(
uint32_t object_instance, BACNET_SUBORDINATE_DATA *subordinate_list);
BACNET_STACK_EXPORT
BACNET_SUBORDINATE_DATA *
Structured_View_Subordinate_List_Member(
uint32_t object_instance, BACNET_ARRAY_INDEX array_index);
BACNET_STACK_EXPORT
unsigned int Structured_View_Subordinate_List_Count(uint32_t object_instance);
BACNET_STACK_EXPORT
BACNET_RELATIONSHIP
@@ -84,6 +90,19 @@ BACNET_STACK_EXPORT
bool Structured_View_Default_Subordinate_Relationship_Set(
uint32_t object_instance, BACNET_RELATIONSHIP relationship);
BACNET_STACK_EXPORT
int Structured_View_Subordinate_List_Element_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX array_index, uint8_t *apdu);
BACNET_STACK_EXPORT
int Structured_View_Subordinate_Annotations_Element_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX array_index, uint8_t *apdu);
BACNET_STACK_EXPORT
int Structured_View_Subordinate_Node_Types_Element_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX array_index, uint8_t *apdu);
BACNET_STACK_EXPORT
int Structured_View_Subordinate_Relationships_Element_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX array_index, uint8_t *apdu);
BACNET_STACK_EXPORT
BACNET_DEVICE_OBJECT_REFERENCE *
Structured_View_Represents(uint32_t object_instance);