Commit Graph

10 Commits

Author SHA1 Message Date
Steve Karg aa87bd8051 Bugfix/ipv6 leave multicast on foreign device registration (#899)
* Fixed IPv6 handler to ignore original-broadcast when registered as a foreign-device

* Fixed IPv6 to leave multicast when registering as foreign device.
2025-02-17 09:07:27 -06:00
Steve Karg 94b3809a58 Bugfix/confirmed handlers empty service request (#885)
* Added reject in all confirmed service handlers, except GetEventInformation, when confirmed services with zero length occur which rejects with required parameters are missing message.

* Refactored errno use in service using debug_perror. Changed debug_perror usage to debug_fprintf. 

* Updated file and function headers in basic/service modules.

* Changed NDPU priority on confirmed messages to use requested NDPU priority.

* Renamed debug_aprintf to debug_printf_stdout for clarity.

* Convert most debug_fprintf usage to debug_print to reduce text bloat in AVR build
2025-01-05 10:09:39 -06:00
Steve Karg 776b212995 Removed strcasecmp and strncasecmp because they are non-standand C functions. (#858) 2024-11-21 12:29:08 -06:00
Patrick Grimm e71c4177a1 fix bsd/bip6.c:35:16: error: variadic macros are a C99 feature (#805)
Copy debug_fprintf_bip6() from linux
2024-10-11 09:46:17 -05:00
Kari Argillander a2f1d6959d Make most of functions const correct (#714)
* Make most of the functions const correct

Used clang-tidy and sonarlint to help find places where const could
pretty easily applied. Also lot of hand work.

This commit does not yet touch handlers and typedefs of those.

* Fix Arduino uno handler_who_is() has extra parenthesis

For some reason there is extra parenthesis. Remove it this is more
likely buildable.

* Bugfix/bacapp: Fix uninitilized array_index

We have changed bacapp_snprintf_value() to be const correct. After that
we got

```
/home/runner/work/bacnet-stack/bacnet-stack/src/bacnet/bacapp.c:3183:27: warning: 4th function call argument is an uninitialized value [core.CallAndMessage]
                ret_val = bacapp_snprintf_weeklyschedule(
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

So analyzer could now spot that we do not actually initilize array_index
at all. Fix this by setting array_index to zero. Note that I actually do
not know if zeroing is right thing to do here. I choose zero as if this
has worked before it is most likely that it will work with zero value.

* cmake: Add and ignore Wwrite-strings compiler option

Wwrite-strings helps find places where const correctness is broken.

Example it will warn about these

```C

void func1(char* str);

func("test") /* "test" is const so we should not pass it to func1().

char* func2()
{
  return "test"; /* func2() should return const char*.
}
```

We still need to ignore it as not all are fixed but let's add it already
so we remember that it should be opened at some point.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-29 14:08:02 -05:00
Kari Argillander 6271632944 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>
2024-08-13 16:32:44 -05:00
Kari Argillander cb243c36a8 Improve SPDX identifier coverage (#716)
* Change MIT license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change GPL exception license texts to SPDX-License-Identifier

SPDX-License-Identifier is much easier to understand and grep than
license text so use that instead.

* Change misc license texts to SPDX-License-Identifier

There are some external code in repo which are not licenses as most of
the stuff in this repo. We still want every file to have SPDX identifier
to easily grep licenses.

* Add currently used license files

Even though Bacnet-Stack is using SPDX identifiers we still need to give
those license files with source. For this reason add all license files
to license/ folder.

SPDX has also files which would make same thing but this is style which
example Linux kernel is using and it is quite clear so I choose that one
for now.

I choosed not yet bring CC-PDDC as that is not right license for those
files.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2024-08-12 15:33:02 -05:00
Patrick Grimm 8e6b3fafab Feature/bacnet ipv6 bind interface for link local comunication (#359) 2022-11-20 14:29:11 -06:00
Patrick Grimm 78fd0cf9cb FIX static timeGetTime, make it similar to linux port (#358) 2022-11-20 14:27:30 -06:00
Patrick Grimm f191ca1a96 Feature/bip6 add ipv6 support for BSD and macOS (#223)
* Fixed bsd compile error ld: unknown option: --gc-sections

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>

* Revert "Fixed bsd compile error ld: unknown option: --gc-sections"

This reverts commit e186e396dadb1875018de8b0e738c05b04c8f7d7.

* Feature/bip6 add bsd support, cp bip6.c from linux port

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>

* Feature/bip6 add bsd support, fix missing member named s6_addr16 in struct in6_addr

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>

* Feature/bip6 add bsd support, rename default ifname from eth0 ton en0

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>

* Feature/bip6 add bsd support, update reference from Linux to BSD and appropriate interface names

Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
2022-02-13 09:32:01 -06:00