From bf7ca623a65f25cc4ac7a3ca0d6635331ec07c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 19 Apr 2018 13:04:41 +0200 Subject: Fix Coverity reports of uninitialized scalar variable Fixes most current reports on Coverity Scan of uninitialized scalar variable (CWE-457): https://cwe.mitre.org/data/definitions/457.html These happen most of the time (in our code) when instanciating structs without a constructor (or with an incomplete one), and later returning the instance. This is sometimes intended though, as some parameters are only used in some situations and should not be double-initialized for performance reasons (e.g. `constant` in ShaderLanguage::Token). --- modules/gdscript/gdscript_editor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 0d52f0a995..a11ee709e6 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -430,6 +430,9 @@ struct GDScriptCompletionIdentifier { Ref script; Variant::Type type; Variant value; //im case there is a value, also return it + + GDScriptCompletionIdentifier() : + type(Variant::NIL) {} }; static GDScriptCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) { @@ -551,9 +554,7 @@ static Ref _get_parent_class(GDScriptCompletionContext &context) { static GDScriptCompletionIdentifier _get_native_class(GDScriptCompletionContext &context) { - //eeh... GDScriptCompletionIdentifier id; - id.type = Variant::NIL; REF pc = _get_parent_class(context); if (!pc.is_valid()) { -- cgit v1.2.3