Fix compiler warnings

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

Remove or mark unused variables.  Fix unsigned/signed comparisons.

bug: 73390805
test: unit tests
Change-Id: Ic523400a5decf82fae733042b260e0c39a087cd3
This commit is contained in:
Fred Gylys-Colwell
2018-02-14 17:16:15 -08:00
parent 901e673085
commit ef0ec145d3
16 changed files with 26 additions and 40 deletions

View File

@@ -43,7 +43,7 @@ class SubLicenseKeySession : public KeySession {
CdmCipherMode* cipher_mode,
const std::string& srm_requirement);
OEMCryptoResult LoadEntitledContentKeys(const std::vector<CryptoKey>& keys) {
OEMCryptoResult LoadEntitledContentKeys(const std::vector<CryptoKey>& /*keys*/) {
return OEMCrypto_ERROR_INVALID_CONTEXT;
}

View File

@@ -586,7 +586,7 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
open_sessions_stream << number_of_open_sessions;
*query_response = open_sessions_stream.str();
} else if (query_token == QUERY_KEY_MAX_NUMBER_OF_SESSIONS) {
size_t maximum_number_of_sessions;
size_t maximum_number_of_sessions = 0;
if (!crypto_session.GetMaxNumberOfSessions(&maximum_number_of_sessions)) {
LOGW("CdmEngine::QueryStatus: GetMaxNumberOfOpenSessions failed");
return UNKNOWN_ERROR;

View File

@@ -1658,7 +1658,7 @@ bool CryptoSession::GetMaxNumberOfSessions(size_t* max) {
return false;
}
size_t max_sessions;
size_t max_sessions = 0;
OEMCryptoResult status = OEMCrypto_GetMaxNumberOfSessions(
requested_security_level_, &max_sessions);
if (OEMCrypto_SUCCESS != status) {

View File

@@ -759,10 +759,10 @@ class Adapter {
OEMCrypto_INITIALIZED_USING_L3_COULD_NOT_OPEN_FACTORY_KEYBOX);
return false;
}
uint8_t keybox[size];
ssize_t size_read = file->Read(reinterpret_cast<char*>(keybox), size);
std::vector<uint8_t> keybox(size);
ssize_t size_read = file->Read(reinterpret_cast<char*>(&keybox[0]), size);
file->Close();
if (level1_.InstallKeybox(keybox, size) != OEMCrypto_SUCCESS) {
if (level1_.InstallKeybox(&keybox[0], size_read) != OEMCrypto_SUCCESS) {
LOGE("Could NOT install keybox from %s. Falling Back to L3.",
filename.c_str());
level1_.Terminate();

View File

@@ -49,7 +49,7 @@ void Log(const char* file, const char* function, int line, LogPriority level,
int len = snprintf(buf, LOG_BUF_SIZE, "[%s(%d):%s] ", filename, line,
function);
if (len < 0) len = 0;
if (len < sizeof(buf)) {
if (static_cast<unsigned int>(len) < sizeof(buf)) {
va_list ap;
va_start(ap, format);
vsnprintf(buf+len, LOG_BUF_SIZE-len, format, ap);

View File

@@ -30,12 +30,12 @@ namespace {
// HTTP response codes.
const int kHttpOk = 200;
const int kHttpBadRequest = 400;
const int kHttpInternalServerError = 500;
// The following two responses are unused, but left here for human debuggers.
// const int kHttpBadRequest = 400;
// const int kHttpInternalServerError = 500;
const uint32_t kMinute = 60;
const uint32_t kClockTolerance = 10;
const uint32_t kTwoMinutes = 120;
const uint32_t kMaxUsageTableSize = 50;
@@ -932,7 +932,6 @@ TEST_F(WvCdmExtendedDurationTest, DecryptionCloseSessionConcurrencyTest) {
TEST_F(WvCdmExtendedDurationTest, UsageOverflowTest) {
Provision();
SubSampleInfo* data = &kEncryptedStreamingClip5SubSample;
TestWvCdmClientPropertySet client_property_set;
TestWvCdmClientPropertySet* property_set = NULL;
@@ -959,7 +958,6 @@ TEST_F(WvCdmExtendedDurationTest, UsageOverflowTest) {
decryptor_.CloseSession(session_id_);
}
uint32_t num_usage_info = 0;
CdmUsageInfo usage_info;
CdmUsageInfoReleaseMessage release_msg;
CdmResponseType status = decryptor_.GetUsageInfo(
@@ -1003,9 +1001,6 @@ TEST_F(WvCdmExtendedDurationTest, AutomatedOfflineSessionReleaseOnTimerEvent) {
uint32_t initial_open_sessions =
QueryStatus(kLevelDefault, wvcdm::QUERY_KEY_NUMBER_OF_OPEN_SESSIONS);
uint32_t max_sessions =
QueryStatus(kLevelDefault, wvcdm::QUERY_KEY_MAX_NUMBER_OF_SESSIONS);
decryptor_.OpenSession(g_key_system, NULL, kDefaultCdmIdentifier, NULL,
&session_id_);
GenerateKeyRequest(kOfflineClip4, kLicenseTypeOffline);
@@ -1059,9 +1054,6 @@ TEST_F(WvCdmExtendedDurationTest, AutomatedOfflineSessionReleaseOnOpenSession) {
uint32_t initial_open_sessions =
QueryStatus(kLevelDefault, wvcdm::QUERY_KEY_NUMBER_OF_OPEN_SESSIONS);
uint32_t max_sessions =
QueryStatus(kLevelDefault, wvcdm::QUERY_KEY_MAX_NUMBER_OF_SESSIONS);
decryptor_.OpenSession(g_key_system, NULL, kDefaultCdmIdentifier, NULL,
&session_id_);
GenerateKeyRequest(kOfflineClip4, kLicenseTypeOffline);
@@ -1398,7 +1390,6 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
decryptor_.CloseSession(session_id_);
// Create usage report and validate
uint32_t num_usage_info = 0;
CdmUsageInfo usage_info;
CdmUsageInfoReleaseMessage release_msg;
CdmResponseType status = decryptor_.GetUsageInfo(

View File

@@ -47,12 +47,11 @@ namespace {
#define N_ELEM(a) (sizeof(a) / sizeof(a[0]))
const char kPathDelimiter = '/';
// HTTP response codes.
const int kHttpOk = 200;
const int kHttpBadRequest = 400;
const int kHttpInternalServerError = 500;
// The following two responses are unused, but left here for human debuggers.
// const int kHttpBadRequest = 400;
// const int kHttpInternalServerError = 500;
// Default license server, can be configured using --server command line option
// Default key id (pssh), can be configured using --keyid command line option

View File

@@ -42,8 +42,6 @@ namespace {
#define N_ELEM(a) (sizeof(a)/sizeof(a[0]))
const char kPathDelimiter = '/';
// HTTP response codes.
const int kHttpOk = 200;
const int kHttpBadRequest = 400;

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -2,7 +2,8 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
-DDYNAMIC_ADAPTER \
-Wno-unused
-Wno-unused \
-Wno-unused-parameter
LOCAL_C_INCLUDES := \
system/core/include \
vendor/widevine/libwvdrmengine/cdm/core/include \

View File

@@ -475,7 +475,6 @@ TEST_F(WVCryptoPluginTest, CommunicatesSecureBufferRequest) {
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
uint32_t bytesWritten = 0;
Status err = Status::OK;
std::string errorDetailMessage;
DestinationBuffer hDestination;
hDestination.type = BufferType::SHARED_MEMORY;
@@ -590,7 +589,6 @@ TEST_F(WVCryptoPluginTest, SetsFlagsForMinimumSubsampleRuns) {
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
uint32_t bytesWritten = 0;
Status err = Status::OK;
std::string errorDetailMessage;
DestinationBuffer hDestination;
hDestination.type = BufferType::SHARED_MEMORY;
@@ -705,7 +703,6 @@ TEST_F(WVCryptoPluginTest, AllowsSessionIdChanges) {
WVCryptoPlugin plugin(blank, 0, cdm.get());
uint32_t bytesWritten = 0;
Status err = Status::OK;
std::string errorDetailMessage;
DestinationBuffer hDestination;
hDestination.type = BufferType::SHARED_MEMORY;

View File

@@ -730,7 +730,6 @@ TEST_F(WVDrmPluginTest, QueriesKeyStatus) {
for (std::map<std::string, std::string>::iterator itr =
expectedLicenseStatus.begin();
itr != expectedLicenseStatus.end(); ++itr) {
const std::string& key = itr->first;
keyValuePair.value = hLicenseStatus[i++].value;
EXPECT_EQ(itr->second.c_str(), std::string(keyValuePair.value.c_str()));
}
@@ -1409,7 +1408,6 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
std::vector<uint8_t> input;
std::vector<uint8_t> iv;
std::vector<uint8_t> output;
bool match;
// Provide expected behavior to support session creation
EXPECT_CALL(*cdm, OpenSession(StrEq("com.widevine"), _, _, _, _))
@@ -1697,7 +1695,6 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
message.assign(messageRaw, messageRaw + kDataSize);
std::vector<uint8_t> signature;
signature.assign(signatureRaw, signatureRaw + kSignatureSize);
bool match;
{
InSequence calls;
@@ -2364,7 +2361,6 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
}
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
Status res;
// Test turning on session sharing
Status status = plugin.setPropertyString(hidl_string("sessionSharing"),
@@ -2461,4 +2457,3 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
} // namespace drm
} // namespace hardware
} // namespace wvdrm