Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VertexLoaderTest: Fix memset assignment warning #9595

Merged

Conversation

Dentomologist
Copy link
Contributor

Testing a fix for Debian unit test warning -Wclass-memaccess.

Initialize and assign members of TVtxDesc and VAT structs directly
instead of using memset.

Fixes -Wclass-memaccess warning from gcc on Debian.
@Dentomologist Dentomologist force-pushed the fix_vertex_loader_test_warnings branch from 0e96e1b to 1cc035e Compare March 19, 2021 04:12
@Dentomologist Dentomologist marked this pull request as ready for review March 19, 2021 06:09
@Pokechu22
Copy link
Contributor

As an alternative to specifying default values in CPMemory.h, this seems to be valid (but is much more awkward looking than when used for single structs):

  TVtxDesc vtx_desc{.low{.Hex = 0}, .high{.Hex = 0}};
  VAT vat{.g0{.Hex = 0}, .g1{.Hex = 0}, .g2{.Hex = 0}};

m_vtx_desc.low.Hex = 0;
m_vtx_desc.high.Hex = 0;

m_vtx_attr.g0.Hex = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened to:

Suggested change
m_vtx_attr.g0.Hex = 0;
m_vtx_attr = {};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work because the copy assignment operator for BitField has been deleted.

I tried creating a copy assignment operator for TVtxDesc and VAT to copy the respective member .Hex fields, but kept getting errors (I believe from the BitFieldArrays in TVtxDesc .low and .high) about the operation not being sane.

@@ -50,8 +48,12 @@ class VertexLoaderTest : public testing::Test
memset(input_memory, 0, sizeof(input_memory));
memset(output_memory, 0xFF, sizeof(input_memory));

memset(&m_vtx_desc, 0, sizeof(m_vtx_desc));
memset(&m_vtx_attr, 0, sizeof(m_vtx_attr));
m_vtx_desc.low.Hex = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened to:

Suggested change
m_vtx_desc.low.Hex = 0;
m_vtx_desc = {};

@Dentomologist Dentomologist force-pushed the fix_vertex_loader_test_warnings branch 2 times, most recently from e3140d0 to 1cc035e Compare March 23, 2021 18:21
@leoetlino leoetlino merged commit 56fdde5 into dolphin-emu:master Jul 6, 2021
10 checks passed
@Dentomologist Dentomologist deleted the fix_vertex_loader_test_warnings branch January 27, 2023 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants