Perform aggregate zero-init instead of .fill(0) where appropriate.
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m50s

Simpler and more consistent code.
This commit is contained in:
hashlag
2026-02-05 00:40:55 +03:00
parent ed22d29af0
commit 95e74db6ec
4 changed files with 17 additions and 38 deletions

View File

@@ -58,11 +58,8 @@ TEST(Arc4CryptTests, UninitializedArc4CryptTest)
Arc4Crypt arc4;
{
std::array<uint8_t, 10> in;
in.fill(0);
std::array<uint8_t, 10> out;
out.fill(0);
std::array<uint8_t, 10> in = {};
std::array<uint8_t, 10> out = {};
ASSERT_THROW(arc4.Encrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
ASSERT_THROW(arc4.Decrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
@@ -117,8 +114,7 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 47> out;
out.fill(0);
std::array<uint8_t, 47> out = {};
std::array<uint8_t, 47> expected =
{
@@ -139,8 +135,7 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 47> out;
out.fill(0);
std::array<uint8_t, 47> out = {};
std::array<uint8_t, 47> expected =
{
@@ -161,11 +156,8 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 44> out;
out.fill(0);
std::array<uint8_t, 44> expected;
expected.fill(0);
std::array<uint8_t, 44> out = {};
std::array<uint8_t, 44> expected = {};
crypt.Encrypt(out.begin() + 3, data.begin(), 0);
@@ -182,8 +174,7 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
{
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 17> out;
out.fill(0);
std::array<uint8_t, 17> out = {};
std::array<uint8_t, 17> expected =
{
@@ -200,8 +191,7 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
{
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 17> out;
out.fill(0);
std::array<uint8_t, 17> out = {};
std::array<uint8_t, 17> expected =
{
@@ -218,11 +208,8 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
{
Arc4Crypt crypt(key.begin(), key.end());
std::array<uint8_t, 14> out;
out.fill(0);
std::array<uint8_t, 14> expected;
expected.fill(0);
std::array<uint8_t, 14> out = {};
std::array<uint8_t, 14> expected = {};
crypt.Decrypt(out.begin() + 3, data.begin(), 0);

View File

@@ -360,8 +360,7 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
Arc4Gen gen(key, key + std::size(key));
std::array<uint8_t, 23> out;
out.fill(0);
std::array<uint8_t, 23> out = {};
std::array<uint8_t, 23> expected =
{
@@ -380,8 +379,7 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
Arc4Gen gen(key, key + std::size(key));
std::array<uint8_t, 23> out;
out.fill(0);
std::array<uint8_t, 23> out = {};
std::array<uint8_t, 23> expected =
{
@@ -400,11 +398,8 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
Arc4Gen gen(key, key + std::size(key));
std::array<uint8_t, 20> out;
out.fill(0);
std::array<uint8_t, 20> expected;
expected.fill(0);
std::array<uint8_t, 20> out = {};
std::array<uint8_t, 20> expected = {};
gen.Generate(out.begin() + 3, 0);

View File

@@ -46,8 +46,7 @@ TEST(DesCryptTests, EncryptTest)
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
const std::array<uint8_t, 8> & key) const
{
std::array<uint8_t, DesCrypt::BlockSize> result;
result.fill(0);
std::array<uint8_t, DesCrypt::BlockSize> result = {};
DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::DesEncryptor enc(desKey);
@@ -206,8 +205,7 @@ TEST(DesCryptTests, DecryptTest)
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
const std::array<uint8_t, 8> & key) const
{
std::array<uint8_t, DesCrypt::BlockSize> result;
result.fill(0);
std::array<uint8_t, DesCrypt::BlockSize> result = {};
DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::DesDecryptor dec(desKey);