From a1225b838f1f4cf4544455abf72dddcbd6372490 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 21 Nov 2019 06:19:44 +0200 Subject: cam: options: Fix unitialized variable warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 8 and 9 complain about the OptionValue::integer_ member being possibly used initialized when compiled in release mode. I haven't been able to find where this could be the case, and the compiler error message isn't helpful: In file included from ../../src/cam/options.cpp:14: ../../src/cam/options.h: In member function ‘bool OptionsBase::parseValue(const T&, const Option&, const char*) [with T = std::__cxx11::basic_string]’: ../../src/cam/options.h:84:7: error: ‘.OptionValue::integer_’ may be used uninitialized in this function [-Werror=maybe-uninitialized] class OptionValue ^~~~~~~~~~~ ../../src/cam/options.h: In member function ‘bool OptionsBase::parseValue(const T&, const Option&, const char*) [with T = int]’: ../../src/cam/options.h:84:7: error: ‘.OptionValue::integer_’ may be used uninitialized in this function [-Werror=maybe-uninitialized] class OptionValue ^~~~~~~~~~~ Furthermore valgrind doesn't report any issue. This is likely a false positive, but fix it nonetheless as the fix is cheap. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/cam/options.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/cam') diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 7e2dfa63..2c56eacf 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -250,7 +250,7 @@ void KeyValueParser::usage(int indent) */ OptionValue::OptionValue() - : type_(ValueNone) + : type_(ValueNone), integer_(0) { } @@ -260,17 +260,17 @@ OptionValue::OptionValue(int value) } OptionValue::OptionValue(const char *value) - : type_(ValueString), string_(value) + : type_(ValueString), integer_(0), string_(value) { } OptionValue::OptionValue(const std::string &value) - : type_(ValueString), string_(value) + : type_(ValueString), integer_(0), string_(value) { } OptionValue::OptionValue(const KeyValueParser::Options &value) - : type_(ValueKeyValue), keyValues_(value) + : type_(ValueKeyValue), integer_(0), keyValues_(value) { } -- cgit v1.2.1