Modify Code to Work with Clang/C++11

Merge from widevine repo of http://go/wvgerrit/15659

The clang compiler is more strict about C++11. This is needed for
future Android work.

In particular, iostream no longer converts to bool automtically, so
those instances were replaced with ss.fail().

Arrays or structures that appear to be variable length need to be
placed last in a structure.  In oemcrypto_test a variable size
structure was replaced with an explicit buffer size, and a check was
added to make sure the buffer is not exceeded.

bug: 20893039
Change-Id: I5e25fc618dcf68262079c15554ee4ceae1858b8b
This commit is contained in:
Fred Gylys-Colwell
2015-09-16 13:26:04 -07:00
parent ff6b79d945
commit bf0c87e734
5 changed files with 35 additions and 30 deletions

View File

@@ -168,7 +168,8 @@ std::string kOfflineClip2PstInitData = wvcdm::a2bs_hex(
bool StringToInt64(const std::string& input, int64_t* output) {
std::istringstream ss(input);
return ss >> *output;
ss >> *output;
return !ss.fail();
}
} // namespace

View File

@@ -2068,13 +2068,15 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyStatus) {
itr = query_info.find(wvcdm::QUERY_KEY_LICENSE_DURATION_REMAINING);
ASSERT_TRUE(itr != query_info.end());
ss.str(itr->second);
ASSERT_TRUE(ss >> remaining_time);
ss >> remaining_time;
ASSERT_FALSE(ss.fail());
EXPECT_LT(0, remaining_time);
itr = query_info.find(wvcdm::QUERY_KEY_PLAYBACK_DURATION_REMAINING);
ASSERT_TRUE(itr != query_info.end());
ss.clear();
ss.str(itr->second);
ASSERT_TRUE(ss >> remaining_time);
ss >> remaining_time;
ASSERT_FALSE(ss.fail());
EXPECT_LT(0, remaining_time);
itr = query_info.find(wvcdm::QUERY_KEY_RENEWAL_SERVER_URL);
@@ -2103,7 +2105,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
ASSERT_TRUE(itr != query_info.end());
std::istringstream ss(itr->second);
uint32_t system_id;
EXPECT_TRUE(ss >> system_id);
ss >> system_id;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
@@ -2138,7 +2141,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
ss.clear();
ss.str(itr->second);
uint32_t open_sessions;
EXPECT_TRUE(ss >> open_sessions);
ss >> open_sessions;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
itr = query_info.find(QUERY_KEY_MAX_NUMBER_OF_SESSIONS);
@@ -2146,7 +2150,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
ss.clear();
ss.str(itr->second);
uint32_t max_sessions;
EXPECT_TRUE(ss >> max_sessions);
ss >> max_sessions;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(open_sessions, max_sessions);
EXPECT_LE(8u, max_sessions);
@@ -2156,7 +2161,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
ss.clear();
ss.str(itr->second);
uint32_t api_version;
EXPECT_TRUE(ss >> api_version);
ss >> api_version;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(10u, api_version);
}
@@ -2181,7 +2187,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
ASSERT_TRUE(itr != query_info.end());
std::istringstream ss(itr->second);
uint32_t system_id;
EXPECT_TRUE(ss >> system_id);
ss >> system_id;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
@@ -2198,7 +2205,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
ASSERT_TRUE(itr != query_info_default.end());
std::istringstream ss(itr->second);
uint32_t default_system_id;
EXPECT_TRUE(ss >> system_id);
ss >> system_id;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_NE(system_id, default_system_id);
}
@@ -2222,7 +2230,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) {
ASSERT_TRUE(itr != query_info.end());
std::istringstream ss;
ss.str(itr->second);
EXPECT_TRUE(ss >> oem_crypto_session_id);
ss >> oem_crypto_session_id;
ASSERT_FALSE(ss.fail());
decryptor_.CloseSession(session_id_);
}

View File

@@ -6,8 +6,6 @@ $(call assert-not-null,test_name)
include $(CLEAR_VARS)
LOCAL_CLANG := false
LOCAL_MODULE := $(test_name)
LOCAL_MODULE_TAGS := tests