From 017f629fc775629dd22422da6d73325b4bc396d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>
Date: Sat, 22 May 2021 17:14:51 +0200
Subject: test: byte-stream-buffer: Initialize data array
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix compiler warning about variable use before being initialized that
appears with gcc 11.1.0.

    test/byte-stream-buffer.cpp:31:63: error: ‘data’ may be used uninitialized [-Werror=maybe-uninitialized]

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/byte-stream-buffer.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/byte-stream-buffer.cpp b/test/byte-stream-buffer.cpp
index d606f146..04ff0571 100644
--- a/test/byte-stream-buffer.cpp
+++ b/test/byte-stream-buffer.cpp
@@ -20,7 +20,12 @@ class ByteStreamBufferTest : public Test
 protected:
 	int run()
 	{
-		std::array<uint8_t, 100> data;
+		/*
+		 * gcc 11.1.0 incorrectly raises a maybe-uninitialized warning
+		 * when calling data.size() below (if the address sanitizer is
+		 * disabled). Silence it by initializing the array.
+		 */
+		std::array<uint8_t, 100> data = {};
 		unsigned int i;
 		uint32_t value;
 		int ret;
-- 
cgit v1.2.1