GCC is able to see that the branch is useless as it can be done at
compile time. Produces shorter assembly with both -O2 and -O3.
https://godbolt.org/z/ejhfxh8Tx
Signed-off-by: Rosen Penev <rosenp@gmail.com>
More readable anyway.
Also remove specific version. Problems have been fixed already. All
versions should work the same now.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Stricter compiler/settings, such as found during a build
on FreeBSD with clang 14, issue warnings of the kind below.
/usr/local/include/exiv2/value.hpp:1272:31: warning: '_MSVC_LANG' is not defined, evaluates to 0 [-Wundef]
Fix: Guard use of _MSVC_LANG by a check.
Personally, I found that MSVC has several feature-specific
checks in predefined macros which might allow for one
standards-based check that matches GCC/clang/MSVC rather than the
split check for C++ standard and MSVC language version settings.
See https://en.cppreference.com/w/cpp/feature_test
I am not building Exiv2 on MSVC, so I cannot test/suggest
anything here.
FreeBSD's getLoadedLibraries() uses libprocstat(3) to obtain
the list of mapped files (libraries). However, the list
obtained from procstat_getfiles() does not only return regular files,
but might also return anonymous objects that have no fs->path.
With exiv2 v0.28, I had also observed crashes with a real TTY,
and the entry->fs_path dereference would crash, even if it
was only for a test "non-null", so we need something more thorough.
Add a check to only consider VNODEs (actual file system entries),
and also make sure that entry->fs_path is defined so we don't
pass a nullptr to the std::string(const char *) constructor when
we are reading corrupt data. std::string((const char *)0)
on FreeBSD 13.2 - calls strlen() and crashes there.
Also get rid of if constexpr for C++11 compatibility. The else condition
results in extra generated code as compilers are not free to promote if
to if constexpr.