Merge "Enabled log formatting warnings."

This commit is contained in:
Alex Dale
2020-09-09 04:13:02 +00:00
committed by Android (Google) Code Review
15 changed files with 105 additions and 91 deletions

View File

@@ -23,7 +23,6 @@
#include "wv_cdm_constants.h"
namespace {
const uint32_t kFourCcCbc1 = 0x63626331;
const uint32_t kFourCcCbcs = 0x63626373;
const uint32_t kFourCcLittleEndianCbc1 = 0x31636263;
@@ -32,10 +31,11 @@ const uint32_t kFourCcCenc = 0x63656e63;
const std::string kEmptyString;
// MAC key in the license are two separate MAC keys (client and server).
constexpr size_t kLicenseMacKeySize = wvcdm::MAC_KEY_SIZE * 2;
} // namespace
namespace wvcdm {
// Protobuf generated classes.
using video_widevine::EncryptedClientIdentification;
using video_widevine::License;
@@ -596,17 +596,17 @@ CdmResponseType CdmLicense::HandleKeyResponse(
mac_key_iv.assign(license.key(i).iv());
// Strip off PKCS#5 padding
mac_keys.assign(license.key(i).key().data(), 2 * MAC_KEY_SIZE);
mac_keys.assign(license.key(i).key().data(), kLicenseMacKeySize);
}
}
if (license.policy().can_renew() ||
(mac_key_iv.size() != 0 || mac_keys.size() != 0)) {
if (mac_key_iv.size() != KEY_IV_SIZE ||
mac_keys.size() != 2 * MAC_KEY_SIZE) {
mac_keys.size() != kLicenseMacKeySize) {
LOGE(
"MAC key/IV size error: expected = %lu/%lu, "
"MAC key/IV size error: expected = %zu/%zu, "
"actual = %zu/%zu (key/iv)",
2 * MAC_KEY_SIZE, KEY_IV_SIZE, mac_keys.size(), mac_key_iv.size());
kLicenseMacKeySize, KEY_IV_SIZE, mac_keys.size(), mac_key_iv.size());
return KEY_SIZE_ERROR_1;
}
}
@@ -1177,7 +1177,7 @@ CdmResponseType CdmLicense::HandleNewEntitledKeys(
if (content_key.size() < CONTENT_KEY_SIZE) {
LOGE(
"Entitled content key too small: "
"expected = %lu, actual = %zu (bytes)",
"expected = %zu, actual = %zu (bytes)",
CONTENT_KEY_SIZE, content_key.size());
return KEY_SIZE_ERROR_2;
} else if (content_key.size() > CONTENT_KEY_SIZE) {

View File

@@ -507,10 +507,10 @@ class WatchDog {
ssize_t size = sizeof(flag);
ssize_t size_written = file->Write(reinterpret_cast<char*>(&flag), size);
if (size != size_written) {
LOGE("Wrote %d bytes, not %d, to file %s", size_written, size,
LOGE("Wrote %zd bytes, not %zd, to file %s", size_written, size,
filename.c_str());
} else {
LOGE("I wrote %d to %s", size_written, filename.c_str());
LOGE("I wrote %zd to %s", size_written, filename.c_str());
}
}

View File

@@ -1055,7 +1055,7 @@ bool UsageTableHeader::LruUpgradeAllUsageEntries() {
bad_license_file_entries.push_back(usage_entry_number);
continue;
default: {
LOGW("Unknown usage entry storage type: %d, usage_entry_number = %u",
LOGW("Unknown usage entry storage type: %d, usage_entry_number = %zu",
static_cast<int>(usage_entry_info.storage_type),
usage_entry_number);
bad_license_file_entries.push_back(usage_entry_number);
@@ -1063,7 +1063,7 @@ bool UsageTableHeader::LruUpgradeAllUsageEntries() {
}
}
if (!retrieve_response) {
LOGW("Could not retrieve license message: usage_entry_number = %u",
LOGW("Could not retrieve license message: usage_entry_number = %zu",
usage_entry_number);
bad_license_file_entries.push_back(usage_entry_number);
continue;
@@ -1071,7 +1071,7 @@ bool UsageTableHeader::LruUpgradeAllUsageEntries() {
if (retrieved_entry_number != usage_entry_number) {
LOGW(
"Usage entry number mismatched: usage_entry_number = %u, "
"Usage entry number mismatched: usage_entry_number = %zu, "
"retrieved_entry_number = %u",
usage_entry_number, retrieved_entry_number);
bad_license_file_entries.push_back(usage_entry_number);
@@ -1080,7 +1080,7 @@ bool UsageTableHeader::LruUpgradeAllUsageEntries() {
video_widevine::License license;
if (!ParseLicenseFromLicenseMessage(license_message, &license)) {
LOGW("Could not parse license: usage_entry_number = %u",
LOGW("Could not parse license: usage_entry_number = %zu",
usage_entry_number);
bad_license_file_entries.push_back(usage_entry_number);
continue;

View File

@@ -109,7 +109,7 @@ class WvCdmEnginePreProvTest : public WvCdmTestBase {
LicenseRequest license_request;
license_request.GetDrmMessage(http_response, *response);
LOGV("response: size=%u, string:\n%s\n", response->size(),
LOGV("response: size = %zu, string =\n%s\n", response->size(),
Base64SafeEncode(
std::vector<uint8_t>(response->begin(), response->end()))
.c_str());
@@ -239,7 +239,7 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
std::string drm_msg;
LicenseRequest lic_request;
lic_request.GetDrmMessage(response, drm_msg);
LOGV("drm msg: %u bytes\r\n%s", drm_msg.size(),
LOGV("drm msg: %zu bytes\r\n%s", drm_msg.size(),
HexEncode(reinterpret_cast<const uint8_t*>(drm_msg.data()),
drm_msg.size())
.c_str());

View File

@@ -41,7 +41,7 @@ void ConcatenateChunkedResponse(const std::string http_response,
sscanf(&http_response[chunk_size_pos], "%zx", &chunk_size);
if (chunk_size > http_response.size()) {
// precaution, in case we misread chunk size
LOGE("invalid chunk size %u", chunk_size);
LOGE("Invalid chunk size %zu", chunk_size);
return;
}
@@ -64,7 +64,7 @@ void ConcatenateChunkedResponse(const std::string http_response,
sscanf(&http_response[chunk_size_pos], "%zx", &chunk_size);
if (chunk_size > http_response.size()) {
// precaution, in case we misread chunk size
LOGE("invalid chunk size %u", chunk_size);
LOGE("Invalid chunk size %zu", chunk_size);
break;
}
chunk_pos = http_response.find(kCrLf, chunk_size_pos);
@@ -104,11 +104,12 @@ bool UrlRequest::GetResponse(std::string* message) {
// non-blocking mode.
while (true) {
char read_buffer[kReadBufferSize];
int bytes = socket_.Read(read_buffer, sizeof(read_buffer), kReadTimeoutMs);
const int bytes =
socket_.Read(read_buffer, sizeof(read_buffer), kReadTimeoutMs);
if (bytes > 0) {
response.append(read_buffer, bytes);
} else if (bytes < 0) {
LOGE("read error, errno = %d", errno);
LOGE("Read error, errno = %d", errno);
return false;
} else {
// end of stream.
@@ -117,7 +118,7 @@ bool UrlRequest::GetResponse(std::string* message) {
}
ConcatenateChunkedResponse(response, message);
LOGV("HTTP response from %s://%s:%d%s: (%zd): %s", socket_.scheme().c_str(),
LOGV("HTTP response from %s://%s:%d%s: (%zu): %s", socket_.scheme().c_str(),
socket_.domain_name().c_str(), socket_.port(),
socket_.resource_path().c_str(), message->size(), message->c_str());
return true;
@@ -204,7 +205,7 @@ bool UrlRequest::PostRequestWithPath(const std::string& path,
const int ret =
socket_.Write(request.c_str(), request.size(), kWriteTimeoutMs);
LOGV("HTTP request: (%d): %s", request.size(), b2a_hex(request).c_str());
LOGV("HTTP request: (%zu): %s", request.size(), b2a_hex(request).c_str());
return ret != -1;
}