Fix deprecated and printf warnings. am: 24e4c33262

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13798628

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic995c1b470c82ddbdd9905cf8c22d61bba779212
This commit is contained in:
Rahul Frias
2021-03-09 19:37:54 +00:00
committed by Automerger Merge Worker
5 changed files with 30 additions and 10 deletions

View File

@@ -7,6 +7,7 @@
#include "crypto_session.h"
#include <inttypes.h>
#include <string.h>
#include <algorithm>
@@ -1745,11 +1746,11 @@ CdmResponseType CryptoSession::GenerateUsageReport(
static_cast<int>(pst_report.pst_length()));
LOGV("OEMCrypto_PST_Report.padding: %d\n",
static_cast<int>(pst_report.padding()));
LOGV("OEMCrypto_PST_Report.seconds_since_license_received: %ld\n",
LOGV("OEMCrypto_PST_Report.seconds_since_license_received: %" PRId64 "\n",
pst_report.seconds_since_license_received());
LOGV("OEMCrypto_PST_Report.seconds_since_first_decrypt: %ld\n",
LOGV("OEMCrypto_PST_Report.seconds_since_first_decrypt: %" PRId64 "\n",
pst_report.seconds_since_first_decrypt());
LOGV("OEMCrypto_PST_Report.seconds_since_last_decrypt: %ld\n",
LOGV("OEMCrypto_PST_Report.seconds_since_last_decrypt: %" PRId64 "\n",
pst_report.seconds_since_last_decrypt());
LOGV("OEMCrypto_PST_Report: %s\n", b2a_hex(*usage_report).c_str());

View File

@@ -558,13 +558,16 @@ bool InitializationData::ConstructWidevineInitData(
// Now format as Widevine init data protobuf
WidevinePsshData cenc_header;
// TODO(rfrias): The algorithm is a deprecated field, but proto changes
// have not yet been pushed to production. Set until then.
// TODO(rfrias): The algorithm and provider are deprecated fields, but proto
// changes have not yet been pushed to production. Set until then.
CORE_UTIL_IGNORE_DEPRECATED
cenc_header.set_algorithm(WidevinePsshData_Algorithm_AESCTR);
cenc_header.set_provider(provider);
CORE_UTIL_RESTORE_WARNINGS
for (size_t i = 0; i < key_ids.size(); ++i) {
cenc_header.add_key_ids(key_ids[i]);
}
cenc_header.set_provider(provider);
cenc_header.set_content_id(content_id);
if (method == kHlsMethodAes128)
cenc_header.set_protection_scheme(kFourCcCbc1);

View File

@@ -716,8 +716,13 @@ TEST_P(HlsConstructionTest, InitData) {
if (param.success_) {
WidevinePsshData cenc_header;
EXPECT_TRUE(cenc_header.ParseFromString(value));
CORE_UTIL_IGNORE_DEPRECATED
EXPECT_EQ(video_widevine::WidevinePsshData_Algorithm_AESCTR,
cenc_header.algorithm());
EXPECT_EQ(param.provider_, cenc_header.provider());
CORE_UTIL_RESTORE_WARNINGS
for (size_t i = 0; i < param.key_ids_.size(); ++i) {
bool key_id_found = false;
if (param.key_ids_[i].size() != 32) continue;
@@ -729,7 +734,6 @@ TEST_P(HlsConstructionTest, InitData) {
}
EXPECT_TRUE(key_id_found);
}
EXPECT_EQ(param.provider_, cenc_header.provider());
std::vector<uint8_t> param_content_id_vec(Base64Decode(param.content_id_));
EXPECT_EQ(
std::string(param_content_id_vec.begin(), param_content_id_vec.end()),
@@ -822,6 +826,8 @@ TEST_P(HlsParseTest, Parse) {
WidevinePsshData cenc_header;
EXPECT_TRUE(cenc_header.ParseFromString(init_data.data()));
CORE_UTIL_IGNORE_DEPRECATED
EXPECT_EQ(video_widevine::WidevinePsshData_Algorithm_AESCTR,
cenc_header.algorithm());
if (param.key_.compare(kJsonProvider) == 0) {
@@ -831,6 +837,7 @@ TEST_P(HlsParseTest, Parse) {
} else if (param.key_.compare(kJsonKeyIds) == 0) {
EXPECT_EQ(param.value_, b2a_hex(cenc_header.key_ids(0)));
}
CORE_UTIL_RESTORE_WARNINGS
EXPECT_EQ(kHlsIvHexValue, b2a_hex(init_data.hls_iv()));
} else {

View File

@@ -78,9 +78,7 @@ struct LoggingUidSetter {
// unit tests.
CORE_UTIL_EXPORT void InitLogging();
// Only enable format specifier warnings on LP64 systems. There is
// no easy portable method to handle format specifiers for int64_t.
#if (defined(__GNUC__) || defined(__clang__)) && defined(__LP64__)
#ifdef __GNUC__
[[gnu::format(printf, 5, 6)]] CORE_UTIL_EXPORT void Log(const char* file,
const char* function,
int line,

View File

@@ -11,12 +11,23 @@
# else
# define CORE_UTIL_EXPORT __declspec(dllimport)
# endif
# define CORE_UTIL_IGNORE_DEPRECATED
# define CORE_UTIL_RESTORE_WARNINGS
#else
# ifdef CORE_UTIL_IMPLEMENTATION
# define CORE_UTIL_EXPORT __attribute__((visibility("default")))
# else
# define CORE_UTIL_EXPORT
# endif
# ifdef __GNUC__
# define CORE_UTIL_IGNORE_DEPRECATED \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
# define CORE_UTIL_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
# else
# define CORE_UTIL_IGNORE_DEPRECATED
# define CORE_UTIL_RESTORE_WARNINGS
# endif
#endif
#endif // WVCDM_UTIL_UTIL_COMMON_H_