Enabled log formatting warnings.

[ Merge of http://go/wvgerrit/105025 ]

Clang and GCC allow for warnings against the arguments for printf-like
functions (e.i. LOGx).  These validate that the format type specified
in the format string match the corresponding argument type.

Most of the time, format specifer errors are benign; hence why they
haven't been seen as an error so far.  However, with the enabling of
specifier warnings and the enabling of warnings as errors on certain
platforms, these existing errors need to be addressed.

This CL enables format specifier warnings for most of the Widevine
code, with the OEMCrypto L3 implementation which has a single error
which requires a fix in the haystack code before being fixed in the
Widevine branch.

Strict format string warnings are not enabled for non-LP64 systems.

Bug: 137583127
Test: Compiled for Linux and Android
Change-Id: I051398332d31a20457b86563a90ad8f6d428445f
This commit is contained in:
Alex Dale
2020-08-21 18:23:44 -07:00
parent 315bf42c4f
commit f22cd20466
15 changed files with 105 additions and 91 deletions

View File

@@ -336,7 +336,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
void LogResponseError(const std::string& message, int http_status_code) {
LOGD("HTTP Status code = %d", http_status_code);
LOGD("HTTP response(%d): %s", message.size(), b2a_hex(message).c_str());
LOGD("HTTP response(%zu): %s", message.size(), b2a_hex(message).c_str());
}
// Post a request and extract the drm message from the response
@@ -360,7 +360,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
if (kHttpOk == http_status_code) {
LicenseRequest lic_request;
lic_request.GetDrmMessage(message, drm_msg);
LOGV("HTTP response body: (%u bytes)", drm_msg.size());
LOGV("HTTP response body: (%zu bytes)", drm_msg.size());
}
key_response_ = drm_msg;
return drm_msg;
@@ -408,7 +408,7 @@ class WvCdmExtendedDurationTest : public WvCdmTestBase {
if (kHttpOk == http_status_code) {
LicenseRequest license;
license.GetDrmMessage(message, usage_info);
LOGV("HTTP response body: (%u bytes)", usage_info.size());
LOGV("HTTP response body: (%zu bytes)", usage_info.size());
}
return usage_info;
}

View File

@@ -242,7 +242,7 @@ class WvCdmFeatureTest : public WvCdmTestBase {
void LogResponseError(const std::string& message, int http_status_code) {
LOGD("HTTP Status code = %d", http_status_code);
LOGD("HTTP response(%d): %s", message.size(), b2a_hex(message).c_str());
LOGD("HTTP response(%zu): %s", message.size(), b2a_hex(message).c_str());
}
// Post a request and extract the signed provisioning message from
@@ -268,13 +268,13 @@ class WvCdmFeatureTest : public WvCdmTestBase {
bool ExtractTokenType(const std::string& b64_provisioning_request_no_pad,
ClientIdentification_TokenType* token_type) {
std::string b64_provisioning_request = b64_provisioning_request_no_pad;
size_t binary_size = b64_provisioning_request.size() * 3 / 4;
const size_t binary_size = b64_provisioning_request.size() * 3 / 4;
// base64 message with pad = 4*ceil[n/3]
size_t pad_size =
const size_t pad_size =
((binary_size + 2) / 3) * 4 - b64_provisioning_request.size();
if (pad_size >= 3) return false;
b64_provisioning_request.append(pad_size, '=');
LOGW("ExtractTokenType: pad_size: %d", pad_size);
LOGW("ExtractTokenType: pad_size: %zu", pad_size);
std::vector<uint8_t> bin_provisioning_request =
Base64SafeDecode(b64_provisioning_request);
@@ -360,7 +360,7 @@ class WvCdmFeatureTest : public WvCdmTestBase {
if (kHttpOk == http_status_code) {
LicenseRequest lic_request;
lic_request.GetDrmMessage(message, drm_msg);
LOGV("HTTP response body: (%u bytes)", drm_msg.size());
LOGV("HTTP response body: (%zu bytes)", drm_msg.size());
}
return drm_msg;
}

View File

@@ -1865,7 +1865,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
void LogResponseError(const std::string& message, int http_status_code) {
LOGD("HTTP Status code = %d", http_status_code);
LOGD("HTTP response(%d): %s", message.size(), b2a_hex(message).c_str());
LOGD("HTTP response(%zu): %s", message.size(), b2a_hex(message).c_str());
}
// Post a request and extract the drm message from the response
@@ -1879,7 +1879,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
std::string message;
EXPECT_TRUE(url_request.GetResponse(&message));
int http_status_code = url_request.GetStatusCode(message);
const int http_status_code = url_request.GetStatusCode(message);
if (kHttpOk != http_status_code) {
LogResponseError(message, http_status_code);
}
@@ -1890,7 +1890,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
if (kHttpOk == http_status_code) {
LicenseRequest lic_request;
lic_request.GetDrmMessage(message, drm_msg);
LOGV("HTTP response body: (%u bytes)", drm_msg.size());
LOGV("HTTP response body: (%zu bytes)", drm_msg.size());
}
return drm_msg;
}
@@ -1927,7 +1927,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
std::string message;
EXPECT_TRUE(url_request.GetResponse(&message));
int http_status_code = url_request.GetStatusCode(message);
const int http_status_code = url_request.GetStatusCode(message);
if (kHttpOk != http_status_code) {
LogResponseError(message, http_status_code);
}
@@ -1937,7 +1937,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
if (kHttpOk == http_status_code) {
LicenseRequest license;
license.GetDrmMessage(message, usage_info);
LOGV("HTTP response body: (%u bytes)", usage_info.size());
LOGV("HTTP response body: (%zu bytes)", usage_info.size());
}
return usage_info;
}
@@ -6167,7 +6167,7 @@ class WvCdmRequestLicenseRollbackTest
protected:
void RollbackSystemTime(time_t rollback_time_ms) {
if (!in_rollback_state_) {
LOGW("Rolling back system time %d ms.", rollback_time_ms);
LOGW("Rolling back system time %ld ms.", rollback_time_ms);
wall_time_before_rollback_ = std::chrono::system_clock::now();
monotonic_time_before_rollback_ = std::chrono::steady_clock::now();
auto modified_wall_time = wall_time_before_rollback_ -