From e7954783530a0fac7f24f81241a3d0e609468638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 27 Aug 2018 13:38:43 +0200 Subject: [PATCH] Make all vars initialized in constructors rather than at some later point. Reported by PVS-Studio, many thanks to @alexesDev for collecting the report. --- src/Magnum/DebugTools/CompareImage.cpp | 2 +- src/Magnum/GL/Context.h | 2 +- src/Magnum/Platform/AbstractXApplication.h | 6 +++--- src/Magnum/Text/AbstractFont.cpp | 4 ++-- src/Magnum/Text/AbstractFont.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Magnum/DebugTools/CompareImage.cpp b/src/Magnum/DebugTools/CompareImage.cpp index f0a31fb4e..a98360675 100644 --- a/src/Magnum/DebugTools/CompareImage.cpp +++ b/src/Magnum/DebugTools/CompareImage.cpp @@ -412,7 +412,7 @@ namespace Corrade { namespace TestSuite { using namespace Magnum; -Comparator::Comparator(Float maxThreshold, Float meanThreshold): _maxThreshold{maxThreshold}, _meanThreshold{meanThreshold} { +Comparator::Comparator(Float maxThreshold, Float meanThreshold): _maxThreshold{maxThreshold}, _meanThreshold{meanThreshold}, _max{}, _mean{} { CORRADE_ASSERT(meanThreshold <= maxThreshold, "DebugTools::CompareImage: maxThreshold can't be smaller than meanThreshold", ); } diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index 1c46a11d2..627dc2d22 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -656,7 +656,7 @@ class MAGNUM_GL_EXPORT Context { MAGNUM_GL_LOCAL bool isCoreProfileImplementationNV(); #endif - void(*_functionLoader)(); + void(*_functionLoader)(){}; Version _version; #ifndef MAGNUM_TARGET_WEBGL Flags _flags; diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index 00e88ce6f..2d28263c0 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -266,9 +266,9 @@ class AbstractXApplication { typedef Containers::EnumSet Flags; CORRADE_ENUMSET_FRIEND_OPERATORS(Flags) - Display* _display; - Window _window; - Atom _deleteWindow; + Display* _display{}; + Window _window{}; + Atom _deleteWindow{}; std::unique_ptr> _contextHandler; std::unique_ptr _context; diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 2680dd845..2e132453e 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -56,9 +56,9 @@ std::vector AbstractFont::pluginSearchPaths() { } #endif -AbstractFont::AbstractFont(): _size(0.0f) {} +AbstractFont::AbstractFont() = default; -AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractPlugin{manager, plugin}, _size{0.0f}, _lineHeight{0.0f} {} +AbstractFont::AbstractFont(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractPlugin{manager, plugin} {} bool AbstractFont::openData(const std::vector>>& data, const Float size) { CORRADE_ASSERT(features() & Feature::OpenData, diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index 6783a1a10..3bc1d6b06 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -361,7 +361,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { #ifdef DOXYGEN_GENERATING_OUTPUT private: #endif - Float _size, _ascent, _descent, _lineHeight; + Float _size{}, _ascent{}, _descent{}, _lineHeight{}; }; CORRADE_ENUMSET_OPERATORS(AbstractFont::Features)