Skip to content

Small fixes#300

Open
izonfreak wants to merge 5 commits into
Beckhoff:masterfrom
izonfreak:small-fixes
Open

Small fixes#300
izonfreak wants to merge 5 commits into
Beckhoff:masterfrom
izonfreak:small-fixes

Conversation

@izonfreak

Copy link
Copy Markdown

This pull request fixes small issues with cmake and warnings inside the AdsLib. The commits can be squash into a single commit but are currently separated for easier review. See commit messages for a more in-depth explanation of some of the fixes.

  • Remove extra warnings on FindTcAdsDll.cmake
  • Fix typo on 'TwinCAT' naming use on cmake.
  • Fix exception handling on AmsRouter.cpp
  • Use prefix u8 for utf-8 string literal.
  • Fix clang-tidy ERR60-CPP rule on AdsException.h

- UTF-8 string literals need to have u8 prefix to them.
 - AdsLibTestRef fails to build under linux. The test is only meant to
   be compile for Windows and FreeBSD systems and should be skiped in
   all other cases.
 - Remove warnings and TODOs from FindTcAdsDll.cmake as the case has now
   been tested and seems to be working.
 - Fix typos on TwinCAT spelling.
 - The variable exception 'e' was unsed in the catch leading to an unsed
   variable warning.
 - Instead of only catching std::exception class. Use catch-all (...)
   handler it catches any exception, regardless of its type. This
   guarantees that lock is released and events are always notify. The
   exception is still propagated at the end.
Fix clang-tidy ERR60-CPP rule "Exception objects must be nothrow copy
constructable".

std::exception is the abstract base class and does not have a
constructor that accepts a string. Since you inherit from it the storage
of the string message for what() needs to be allocated in the
constructor of AdsException in this case using a std::string. Allocating
a std::string can theoretically throw (e.g. bad_alloc). If your
exception is copy more than once during stack unwinding you will not be
able to catch anything.

To solve this simply use std::runtime_error which comes with string
constructors and noexcept copy constructors.

Note here that errorCode should not be a public member of the exception
as one also can theoretically, throw the const away and modify the
value which is not something you want. However, this is leave "as is"
for compatibility reasons.
 - Wrong target TcAdsLib was name for target_compile_definitions when building a
   shared library. It should be AdsLib.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants