Alex Richardson has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/68517?usp=email )
Change subject: tests: Fix GCC -W(maybe-)uninitialized warnings
......................................................................
tests: Fix GCC -W(maybe-)uninitialized warnings
These all look like valid (but harmless) diagnostics to me and are
all simple to fix. Most of them can be fixed by using ASSERT_* variants
of the GTest checkers to ensure that the remainder of the function is
not executed and the uninitialized result isn't touched.
Change-Id: Ib5fe2ac2ec539c880d670ebc3321ce98940c7e38
---
M src/base/circlebuf.test.cc
M src/base/str.test.cc
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/base/circlebuf.test.cc b/src/base/circlebuf.test.cc
index 02fe396..c7913f7 100644
--- a/src/base/circlebuf.test.cc
+++ b/src/base/circlebuf.test.cc
@@ -136,7 +136,7 @@
TEST(CircleBufTest, ProduceConsumeEmpty)
{
CircleBuf<char> buf(8);
- char foo[1];
+ char foo[1] = {'a'};
// buf is empty to begin with.
EXPECT_TRUE(buf.empty());
diff --git a/src/base/str.test.cc b/src/base/str.test.cc
index f999c98..815c553 100644
--- a/src/base/str.test.cc
+++ b/src/base/str.test.cc
@@ -254,7 +254,7 @@
{
int8_t output;
std::string input = "-128";
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(-128, output);
}
@@ -276,7 +276,7 @@
{
uint8_t output;
std::string input = "255";
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(255, output);
}
@@ -292,11 +292,11 @@
{
uint8_t output;
std::string input_1 = "2.99";
- EXPECT_TRUE(to_number(input_1, output));
+ ASSERT_TRUE(to_number(input_1, output));
EXPECT_EQ(2, output);
std::string input_2 = "3.99";
- EXPECT_TRUE(to_number(input_2, output));
+ ASSERT_TRUE(to_number(input_2, output));
EXPECT_EQ(3, output);
}
@@ -308,7 +308,7 @@
{
uint8_t output;
std::string input = "255.99";
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(255, output);
}
@@ -344,7 +344,7 @@
int64_t output;
int64_t input_number = 0xFFFFFFFFFFFFFFFF;
std::string input = std::to_string(input_number);
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(input_number, output);
}
@@ -363,7 +363,7 @@
};
Number output;
std::string input = "2";
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(TWO, output);
}
@@ -384,7 +384,7 @@
float output;
std::string input = "0.1";
float expected_output = 0.1;
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(expected_output, output);
}
@@ -393,7 +393,7 @@
float output;
std::string input = "10";
float expected_output = 10.0;
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(expected_output, output);
}
@@ -402,7 +402,7 @@
float output;
std::string input = "-0.1";
float expected_output = -0.1;
- EXPECT_TRUE(to_number(input, output));
+ ASSERT_TRUE(to_number(input, output));
EXPECT_EQ(expected_output, output);
}
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/68517?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib5fe2ac2ec539c880d670ebc3321ce98940c7e38
Gerrit-Change-Number: 68517
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Richardson <alexrichard...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org