emilk / loguru

A lightweight C++ logging library
The Unlicense
1.77k stars 256 forks source link

Cleanup static analyzer issues #179

Open kcgen opened 3 years ago

kcgen commented 3 years ago

This PR fixes issues flagged by the Clang static analyzer, Coverity, and PVS Studio. Suggest reviewing commit-by-commit, for which the following provides more background.


Uninitialized member variables, flagged by GCC and PVS Studio

../submodules/loguru/loguru.cpp:1491:9: warning: 'loguru::LogScopeRAII::_indent_stderr' should be initialized in the member initialization list
../submodules/loguru/loguru.cpp:1491:9: warning: 'loguru::LogScopeRAII::_start_time_ns' should be initialized in the member initialization list
../submodules/loguru/loguru.cpp:1630:16: warning: 'loguru::StringStream::str' should be initialized in the member initialization list
../submodules/loguru/loguru.cpp:1725:9: warning: 'loguru::EcEntryBase::_previous' should be initialized in the member initialization list 

2021-08-22_20-25


Unused position increment (clarify intent), flagged by Clang's static analyzer

2021-08-22_22-59


Simplify empty std::string operations (1/2), flagged by PVS Studio

2021-08-22_22-46

Simplify empty std::string operations (2/2), flagged by PVS Studio

2021-08-22_20-40


Potential nullptr dereference, flagged by PVS Studio

2021-08-22_20-47


Clarify criteria by removing redundancy, flagged by PVS Studio

2021-08-22_20-42

2021-08-22_20-36

If it makes sense to keep keep them, I could see them be valid as asserts orCHECK_F`s -- let me know.


Virtualize EcEntryBase's destructor so it's called by derived classes, flagged by LGTM

2021-08-24_12-24


Explicitly ignore sigaction's return value, flagged by Coverity

2021-08-24_12-23

kcgen commented 3 years ago

Re-sync'd with latest changes in master.

kcgen commented 3 years ago

Recently merged PR#180 introduce two new PVS Studio warnings:

2021-09-16_08-33 2021-09-16_08-31

This branch now fixes these as well, in commit: https://github.com/dosbox-staging/loguru/commit/0155fe9552c470754e1c1919d3cf7f7df90a21ff