Skip to content

Commit

Permalink
build: Fix compilation warnings for GCC 12
Browse files Browse the repository at this point in the history
- Remove unnecessary nullptr test that triggered -Waddress.
- Initialize test buffers before they're used.
- Use unique names for the trace_id variable to avoid shadowing.

Bug: b/271485754
Change-Id: Iaac18f7a82fae70623b0af0cdd4a1691f47334b2
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/132030
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Wyatt Hepler <[email protected]>
Reviewed-by: Ewout van Bekkum <[email protected]>
  • Loading branch information
255 authored and CQ Bot Account committed Mar 4, 2023
1 parent 9d2776b commit 962a0df
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions pw_build/cc_blob_library_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ namespace pw::build {
namespace {

static_assert(test::ns::kFirstBlob0123.size() == 4);
static_assert(test::ns::kFirstBlob0123.data() != nullptr);

static_assert(test::ns::kSecondBlob0123.size() == 4);
static_assert(test::ns::kSecondBlob0123.data() != nullptr);

TEST(CcBlobLibraryTest, FirstBlobContentsMatch) {
EXPECT_EQ(test::ns::kFirstBlob0123[0], std::byte{0});
Expand Down
4 changes: 2 additions & 2 deletions pw_hdlc/encoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ constexpr uint8_t kEncodedAddress = (kAddress << 1) | 1;

class WriteUnnumberedFrame : public ::testing::Test {
protected:
WriteUnnumberedFrame() : writer_(buffer_) {}
WriteUnnumberedFrame() : buffer_{}, writer_(buffer_) {}

stream::MemoryWriter writer_;
// Allocate a buffer that will fit any 7-byte payload.
std::array<byte, MaxEncodedFrameSize(7)> buffer_;
stream::MemoryWriter writer_;
};

constexpr byte kUnnumberedControl = byte{0x3};
Expand Down
2 changes: 1 addition & 1 deletion pw_log_rpc/log_filter_service_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class FilterServiceTest : public ::testing::Test {
FilterServiceTest() : filter_map_(filters_) {}

protected:
FilterMap filter_map_;
static constexpr size_t kMaxFilterRules = 4;
std::array<Filter::Rule, kMaxFilterRules> rules1_;
std::array<Filter::Rule, kMaxFilterRules> rules2_;
Expand All @@ -58,6 +57,7 @@ class FilterServiceTest : public ::testing::Test {
Filter(filter_id2_, rules2_),
Filter(filter_id3_, rules3_),
};
FilterMap filter_map_;
};

TEST_F(FilterServiceTest, GetFilterIds) {
Expand Down
2 changes: 1 addition & 1 deletion pw_multisink/multisink_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MultiSinkTest : public ::testing::Test {
static constexpr size_t kEntryBufferSize = 1024;
static constexpr size_t kBufferSize = 5 * kEntryBufferSize;

MultiSinkTest() : multisink_(buffer_) {}
MultiSinkTest() : buffer_{}, multisink_(buffer_) {}

// Expects the peeked or popped message to equal the provided non-empty
// message, and the drop count to match. If `expected_message` is empty, the
Expand Down
6 changes: 4 additions & 2 deletions pw_trace/public/pw_trace/internal/trace_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@ static inline void _pw_trace_disabled(int x, ...) { (void)x; }
object_name(object_name&&) = delete; \
object_name& operator=(const object_name&) = delete; \
object_name& operator=(object_name&&) = delete; \
object_name(uint32_t trace_id = PW_TRACE_TRACE_ID_DEFAULT) \
: trace_id_(trace_id) { \
\
object_name(uint32_t PW_CONCAT(object_name, \
_trace_id) = PW_TRACE_TRACE_ID_DEFAULT) \
: trace_id_(PW_CONCAT(object_name, _trace_id)) { \
_PW_TRACE_IF_ENABLED(event_type_start, flag, label, group, trace_id_); \
} \
~object_name() { \
Expand Down

0 comments on commit 962a0df

Please sign in to comment.