Skip to content

Commit

Permalink
[libromdata] WiiUPackage: Use std::array<uint8_t, 16> for iv.
Browse files Browse the repository at this point in the history
Fixes a clang-tidy warning:

src/libromdata/Console/WiiUPackage.cpp:171:3: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
  171 |                 uint8_t iv[16];
      |                 ^

Also, use array::fill() instead of memset(), since array::fill() will
generate 128-bit SIMD code with most modern compilers. (memset() probably
would as well, if clearing the full 16 bytes instead of just 14...)
  • Loading branch information
GerbilSoft committed Nov 9, 2024
1 parent 113191b commit 48e0bbf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libromdata/Console/WiiUPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ IDiscReaderPtr WiiUPackagePrivate::openContentFile(unsigned int idx)
// Content is not H3-hashed.

// IV is the 2-byte content index, followed by zeroes.
uint8_t iv[16];
memcpy(iv, &entry.index, 2);
memset(&iv[2], 0, 14);
array<uint8_t, 16> iv;
iv.fill(0);
memcpy(iv.data(), &entry.index, 2);

discReader = std::make_shared<CBCReader>(subfile, 0, subfile->size(), title_key, iv);
discReader = std::make_shared<CBCReader>(subfile, 0, subfile->size(), title_key, iv.data());
}
if (!discReader->isOpen()) {
// Unable to open the CBC reader.
Expand Down

0 comments on commit 48e0bbf

Please sign in to comment.