Skip to content

Commit

Permalink
Fix compiler warnings in GCC-13 (Noble) (#616)
Browse files Browse the repository at this point in the history
GCC-13 is complaining about "pointers returned from a mismatched
allocation function" in the UNIT_ImageDisplay_TEST. There are
3 occurences where a shared pointer is created from a simple
type while the object handled is really a C array.

The commit changes the type to indicate that it is in fact
an array.

Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
  • Loading branch information
j-rivero authored Apr 10, 2024
1 parent 648c8b7 commit a4710e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugins/image_display/ImageDisplay_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ TEST(ImageDisplayTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ReceiveImage))

// red image
int bufferSize = msg.width() * msg.height() * bpp;
std::shared_ptr<unsigned char> buffer(new unsigned char[bufferSize]);
std::shared_ptr<unsigned char[]> buffer(new unsigned char[bufferSize]);
for (int i = 0; i < bufferSize; i += bpp)
{
buffer.get()[i] = 255u;
Expand Down Expand Up @@ -371,7 +371,7 @@ TEST(ImageDisplayTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ReceiveImageFloat32))

// first half is gray, second half is black
int bufferSize = msg.width() * msg.height() * bpp;
std::shared_ptr<float> buffer(new float[bufferSize]);
std::shared_ptr<float[]> buffer(new float[bufferSize]);
for (unsigned int y = 0; y < msg.width(); ++y)
{
float v = 0.5f * static_cast<int>(y / (msg.height() / 2.0) + 1);
Expand Down Expand Up @@ -485,7 +485,7 @@ TEST(ImageDisplayTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ReceiveImageInt16))

// first half is black, second half is white
int bufferSize = msg.width() * msg.height() * bpp;
std::shared_ptr<uint16_t> buffer(new uint16_t[bufferSize]);
std::shared_ptr<uint16_t[]> buffer(new uint16_t[bufferSize]);
for (unsigned int y = 0; y < msg.width(); ++y)
{
uint16_t v = 100 * static_cast<int>(y / (msg.height() / 2.0) + 1);
Expand Down

0 comments on commit a4710e9

Please sign in to comment.