Fix or ignore compiler warnings

Merge from Widevine repo of http://go/wvgerrit/24688

b/35466719

Change-Id: If89f0cad0c61f37536a84f8dadaf08072356343a
This commit is contained in:
Fred Gylys-Colwell
2017-03-21 15:09:02 -07:00
parent c4aad89fd0
commit 85365a1497
6 changed files with 35 additions and 31 deletions

View File

@@ -277,7 +277,7 @@ TEST_F(OEMCryptoClientTest, GetRandomLargeBuffer) {
// We don't have enough data to see that the data is really random,
// so we'll just do a spot check that two calls don't return the same values.
int count = 0;
for (int i = 0; i < size; i++) {
for (size_t i = 0; i < size; i++) {
if (data1[i] == data2[i]) count++;
}
ASSERT_LE(count, 3); // P(count > 3) = 1/256^3 = 6e-8.
@@ -505,7 +505,7 @@ TEST_F(OEMCryptoKeyboxTest, GenerateDerivedKeysFromKeyboxLargeBuffer) {
vector<uint8_t> mac_context(kMaxMessageSize);
vector<uint8_t> enc_context(kMaxMessageSize);
// Stripe the data so the two vectors are not identical, and not all zeroes.
for (int i = 0; i < kMaxMessageSize; i++) {
for (size_t i = 0; i < kMaxMessageSize; i++) {
mac_context[i] = i % 0x100;
enc_context[i] = (3 * i) % 0x100;
}
@@ -764,8 +764,7 @@ class OEMCryptoSessionTests : public OEMCryptoClientTest {
ASSERT_NO_FATAL_FAILURE(
s.MakeRSACertificate(&encrypted, sizeof(encrypted), &signature,
allowed_schemes, encoded_rsa_key_, &message_key));
ASSERT_NO_FATAL_FAILURE(s.RewrapRSAKey30(encrypted, sizeof(encrypted),
encrypted_message_key,
ASSERT_NO_FATAL_FAILURE(s.RewrapRSAKey30(encrypted, encrypted_message_key,
&wrapped_rsa_key_, force));
// Verify that the clear key is not contained in the wrapped key.
// It should be encrypted.
@@ -946,7 +945,7 @@ TEST_F(OEMCryptoSessionTests, ClientSignatureLargeBuffer) {
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys("", false));
vector<uint8_t> context(kMaxMessageSize);
for (int i = 0; i < kMaxMessageSize; i++) {
for (size_t i = 0; i < kMaxMessageSize; i++) {
context[i] = i % 0x100;
}
static const uint32_t SignatureBufferMaxLength = 256;
@@ -1180,11 +1179,11 @@ class SessionTestAlternateVerification : public OEMCryptoSessionTests,
public:
virtual void SetUp() {
OEMCryptoSessionTests::SetUp();
target_api_ = GetParam();
target_api_ = static_cast<uint32_t>(GetParam());
}
protected:
int target_api_;
uint32_t target_api_;
};
TEST_P(SessionTestAlternateVerification, LoadKeys) {
@@ -1197,7 +1196,7 @@ TEST_P(SessionTestAlternateVerification, LoadKeys) {
if (target_api_ > 8 && target_api_ < 100) {
snprintf(buffer, 5, "kc%02d", target_api_);
}
for (int i = 0; i < s.num_keys(); i++) {
for (size_t i = 0; i < s.num_keys(); i++) {
memcpy(s.license().keys[i].control.verification, buffer, 4);
}
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
@@ -1386,7 +1385,7 @@ TEST_F(OEMCryptoSessionTests, Minimum20KeysAPI12) {
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0, 0, 0));
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
for (int key_index = 0; key_index < kMaxNumKeys; key_index++) {
for (size_t key_index = 0; key_index < kMaxNumKeys; key_index++) {
bool kSelectKeyFirst = true;
ASSERT_NO_FATAL_FAILURE(
s.TestDecryptCTR(kSelectKeyFirst, OEMCrypto_SUCCESS, key_index));
@@ -1707,7 +1706,8 @@ class OEMCryptoSessionTestsDecryptTests
// Partial block. Don't increment iv. Compute next block offset.
block_offset = block_offset + size;
} else {
EXPECT_EQ(AES_BLOCK_SIZE, block_offset + size);
EXPECT_EQ(static_cast<size_t>(AES_BLOCK_SIZE),
block_offset + size);
// Full block. Increment iv, and set offset to 0 for next block.
ctr128_inc64(1, iv);
block_offset = 0;
@@ -1751,7 +1751,7 @@ class OEMCryptoSessionTestsDecryptTests
if (decrypt_inplace_) { // Use same buffer for input and output.
// Copy the useful data from encryptedData to output_buffer, which
// will be the same as input_buffer. Leave the 0xaa padding at the end.
for(int i=0; i < total_size_; i++) output_buffer[i] = encryptedData[i];
for(size_t i=0; i < total_size_; i++) output_buffer[i] = encryptedData[i];
// Now let input_buffer point to the same data.
input_buffer = &output_buffer[0];
} else {
@@ -2479,7 +2479,7 @@ TEST_F(OEMCryptoLoadsCertificate, TestLargeRSAKey3072) {
// Devices that load certificates, should at least support RSA 2048 keys.
TEST_F(OEMCryptoLoadsCertificate, SupportsCertificatesAPI13) {
ASSERT_NE(0,
ASSERT_NE(0u,
OEMCrypto_Supports_RSA_2048bit & OEMCrypto_SupportedCertificates())
<< "Supported certificates is only " << OEMCrypto_SupportedCertificates();
}
@@ -2686,7 +2686,7 @@ TEST_F(OEMCryptoUsesCertificate, GenerateDerivedKeysLargeBuffer) {
vector<uint8_t> mac_context(kMaxMessageSize);
vector<uint8_t> enc_context(kMaxMessageSize);
// Stripe the data so the two vectors are not identical, and not all zeroes.
for (int i = 0; i < kMaxMessageSize; i++) {
for (size_t i = 0; i < kMaxMessageSize; i++) {
mac_context[i] = i % 0x100;
enc_context[i] = (3 * i) % 0x100;
}
@@ -3061,7 +3061,7 @@ class OEMCryptoCastReceiverTest : public OEMCryptoLoadsCertificateAlternates {
// CAST Receivers should report that they support cast certificates.
TEST_F(OEMCryptoCastReceiverTest, SupportsCertificatesAPI13) {
ASSERT_NE(0, OEMCrypto_Supports_RSA_CAST & OEMCrypto_SupportedCertificates());
ASSERT_NE(0u, OEMCrypto_Supports_RSA_CAST & OEMCrypto_SupportedCertificates());
}
// # PKCS#1 v1.5 Signature Example 15.1
@@ -4607,7 +4607,7 @@ TEST_F(UsageTableTest, TwoHundredEntries) {
s1.get_nonce(), pst1));
ASSERT_NO_FATAL_FAILURE(s1.EncryptAndSign());
ASSERT_NO_FATAL_FAILURE(s1.CreateNewUsageEntry());
ASSERT_EQ(s1.usage_entry_number(), 0);
ASSERT_EQ(0u, s1.usage_entry_number());
time_t start = time(NULL);
ASSERT_NO_FATAL_FAILURE(s1.LoadTestKeys(pst1, new_mac_keys_));
ASSERT_NO_FATAL_FAILURE(s1.UpdateUsageEntry(&encrypted_usage_header_));