From patchwork Sat Nov 23 08:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2345 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CD036136B for ; Sat, 23 Nov 2019 09:37:15 +0100 (CET) Received: from pendragon.ideasonboard.com (85-76-114-182-nat.elisa-mobile.fi [85.76.114.182]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C7B1440 for ; Sat, 23 Nov 2019 09:37:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1574498234; bh=KEy3FO7jFnPElfCjogA9BOne/uHWiu5SZalWxbgzAIs=; h=From:To:Subject:Date:From; b=iphVvYAeSBIY+kTqdw3feYigMo6yuFCzlykgXfEgiCXav5fh5e2lVhZQS+5+yvPNk stTxJ/X9Nsau344VMXTERD0L2zuQxhtVrOXP28nmIigyneCNFhcXe6ZC7qA1VIQvLP zWoZN9wJTVwoeJFjYwyE3jn9TglRRhzKq2q5K42o= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 23 Nov 2019 10:36:51 +0200 Message-Id: <20191123083651.6944-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] cam: options: Fix unitialized variable warning X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Nov 2019 08:37:15 -0000 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cam/options.cpp b/src/cam/options.cpp index 7e2dfa636ccf..186e853c8294 100644 --- a/src/cam/options.cpp +++ b/src/cam/options.cpp @@ -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) { }