Commit 6b3cb69d authored by pedroGitt's avatar pedroGitt
Browse files

Fix compiler warnings

- for 32bits platform target
- when debug flag is not defined
parent acafa69c
...@@ -37,7 +37,7 @@ OlmAccount* initializeAccountMemory() ...@@ -37,7 +37,7 @@ OlmAccount* initializeAccountMemory()
if(NULL != (accountPtr=(OlmAccount*)malloc(accountSize))) if(NULL != (accountPtr=(OlmAccount*)malloc(accountSize)))
{ // init account object { // init account object
accountPtr = olm_account(accountPtr); accountPtr = olm_account(accountPtr);
LOGD("## initializeAccountMemory(): success - OLM account size=%lu",accountSize); LOGD("## initializeAccountMemory(): success - OLM account size=%lu",static_cast<long unsigned int>(accountSize));
} }
else else
{ {
...@@ -107,7 +107,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thi ...@@ -107,7 +107,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thi
{ {
// get random buffer size // get random buffer size
randomSize = olm_create_account_random_length(accountPtr); randomSize = olm_create_account_random_length(accountPtr);
LOGD("## initNewAccount(): randomSize=%lu", randomSize); LOGD("## initNewAccount(): randomSize=%lu", static_cast<long unsigned int>(randomSize));
// allocate random buffer // allocate random buffer
if((0!=randomSize) && !setRandomInBuffer(&randomBuffPtr, randomSize)) if((0!=randomSize) && !setRandomInBuffer(&randomBuffPtr, randomSize))
...@@ -181,7 +181,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject ...@@ -181,7 +181,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject
else else
{ {
env->SetByteArrayRegion(byteArrayRetValue, 0/*offset*/, identityKeysLength, (const jbyte*)identityKeysBytesPtr); env->SetByteArrayRegion(byteArrayRetValue, 0/*offset*/, identityKeysLength, (const jbyte*)identityKeysBytesPtr);
LOGD("## identityKeys(): success - result=%ld", keysResult); LOGD("## identityKeys(): success - result=%lu", static_cast<long unsigned int>(keysResult));
} }
} }
...@@ -212,7 +212,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(maxOneTimeKeys)(JNIEnv *env, jobject thiz) ...@@ -212,7 +212,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(maxOneTimeKeys)(JNIEnv *env, jobject thiz)
{ {
maxKeys = olm_account_max_number_of_one_time_keys(accountPtr); maxKeys = olm_account_max_number_of_one_time_keys(accountPtr);
} }
LOGD("## maxOneTimeKey(): Max keys=%ld", maxKeys); LOGD("## maxOneTimeKey(): Max keys=%lu", static_cast<long unsigned int>(maxKeys));
return (jlong)maxKeys; return (jlong)maxKeys;
} }
...@@ -238,7 +238,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeys)(JNIEnv *env, jobject th ...@@ -238,7 +238,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeys)(JNIEnv *env, jobject th
else else
{ // keys memory allocation { // keys memory allocation
randomLength = olm_account_generate_one_time_keys_random_length(accountPtr, (size_t)aNumberOfKeys); randomLength = olm_account_generate_one_time_keys_random_length(accountPtr, (size_t)aNumberOfKeys);
LOGD("## generateOneTimeKeys(): randomLength=%ld", randomLength); LOGD("## generateOneTimeKeys(): randomLength=%lu", static_cast<long unsigned int>(randomLength));
if((0!=randomLength) && !setRandomInBuffer(&randomBufferPtr, randomLength)) if((0!=randomLength) && !setRandomInBuffer(&randomBufferPtr, randomLength))
{ {
...@@ -256,7 +256,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeys)(JNIEnv *env, jobject th ...@@ -256,7 +256,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeys)(JNIEnv *env, jobject th
else else
{ {
retCode = ERROR_CODE_OK; retCode = ERROR_CODE_OK;
LOGD("## generateOneTimeKeys(): success - result=%ld", result); LOGD("## generateOneTimeKeys(): success - result=%lu", static_cast<long unsigned int>(result));
} }
} }
} }
...@@ -386,7 +386,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(markOneTimeKeysAsPublishedJni)(JNIEnv *env, ...@@ -386,7 +386,7 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(markOneTimeKeysAsPublishedJni)(JNIEnv *env,
} }
else else
{ {
LOGD("## markOneTimeKeysAsPublishedJni(): success - retCode=%ld",result); LOGD("## markOneTimeKeysAsPublishedJni(): success - retCode=%lu",static_cast<long unsigned int>(result));
} }
} }
...@@ -429,7 +429,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz ...@@ -429,7 +429,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
// signature memory allocation // signature memory allocation
signatureLength = olm_account_signature_length(accountPtr); signatureLength = olm_account_signature_length(accountPtr);
if(NULL == (signedMsgPtr = (void*)malloc(signatureLength*sizeof(uint8_t)))) if(NULL == (signedMsgPtr = (void*)malloc((signatureLength+1)*sizeof(uint8_t))))
{ {
LOGE("## signMessageJni(): failure - signature allocation OOM"); LOGE("## signMessageJni(): failure - signature allocation OOM");
} }
...@@ -446,10 +446,11 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz ...@@ -446,10 +446,11 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
} }
else else
{ {
// TODO check if signedMsgPtr needs to be null ended: signedMsgPtr[resultSign]='\0' // info: signatureLength is always equal to resultSign
(static_cast<char*>(signedMsgPtr))[signatureLength] = static_cast<char>('\0');
// convert to jstring // convert to jstring
signedMsgRetValue = env->NewStringUTF((const char*)signedMsgPtr); // UTF8 signedMsgRetValue = env->NewStringUTF((const char*)signedMsgPtr); // UTF8
LOGD("## signMessageJni(): success - retCode=%ld",resultSign); LOGD("## signMessageJni(): success - retCode=%lu signatureLength=%lu", static_cast<long unsigned int>(resultSign), static_cast<long unsigned int>(signatureLength));
} }
free(signedMsgPtr); free(signedMsgPtr);
...@@ -533,7 +534,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job ...@@ -533,7 +534,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{ {
size_t pickledLength = olm_pickle_account_length(accountPtr); size_t pickledLength = olm_pickle_account_length(accountPtr);
size_t keyLength = (size_t)env->GetStringUTFLength(aKey); size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",pickledLength, keyLength); LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t)))) if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t))))
...@@ -562,7 +563,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job ...@@ -562,7 +563,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
// build success output // build success output
(static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0');
pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr);
LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", result, static_cast<char*>(pickledPtr)); LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr));
} }
} }
} }
...@@ -616,7 +617,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j ...@@ -616,7 +617,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
{ {
size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData); size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
size_t keyLength = (size_t)env->GetStringUTFLength(aKey); size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",pickledLength, keyLength); LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
...@@ -633,7 +634,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j ...@@ -633,7 +634,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
} }
else else
{ {
LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", result); LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result));
} }
} }
......
...@@ -27,7 +27,7 @@ JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env ...@@ -27,7 +27,7 @@ JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env
{ {
OlmInboundGroupSession* sessionPtr = NULL; OlmInboundGroupSession* sessionPtr = NULL;
LOGD("## releaseSessionJni(): intbound group session"); LOGD("## releaseSessionJni(): InBound group session IN");
if(NULL == (sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz))) if(NULL == (sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz)))
{ {
...@@ -38,7 +38,7 @@ JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env ...@@ -38,7 +38,7 @@ JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env
LOGD(" ## releaseSessionJni(): sessionPtr=%p",sessionPtr); LOGD(" ## releaseSessionJni(): sessionPtr=%p",sessionPtr);
size_t retCode = olm_clear_inbound_group_session(sessionPtr); size_t retCode = olm_clear_inbound_group_session(sessionPtr);
LOGI(" ## releaseSessionJni(): clear_inbound_group_session=%lu",retCode); LOGI(" ## releaseSessionJni(): clear_inbound_group_session=%lu",static_cast<long unsigned int>(retCode));
LOGD(" ## releaseSessionJni(): free IN"); LOGD(" ## releaseSessionJni(): free IN");
free(sessionPtr); free(sessionPtr);
...@@ -67,7 +67,7 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv * ...@@ -67,7 +67,7 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *
else if(NULL != (sessionPtr=(OlmInboundGroupSession*)malloc(sessionSize))) else if(NULL != (sessionPtr=(OlmInboundGroupSession*)malloc(sessionSize)))
{ {
sessionPtr = olm_inbound_group_session(sessionPtr); sessionPtr = olm_inbound_group_session(sessionPtr);
LOGD(" ## createNewSessionJni(): success - inbound group session size=%lu",sessionSize); LOGD(" ## createNewSessionJni(): success - inbound group session size=%lu",static_cast<long unsigned int>(sessionSize));
} }
else else
{ {
...@@ -106,7 +106,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes ...@@ -106,7 +106,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
else else
{ {
size_t sessionKeyLength = (size_t)env->GetStringUTFLength(aSessionKey); size_t sessionKeyLength = (size_t)env->GetStringUTFLength(aSessionKey);
LOGD(" ## initInboundSessionFromIdKeyJni(): sessionKeyLength=%lu",sessionKeyLength); LOGD(" ## initInboundSessionFromIdKeyJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength));
sessionResult = olm_init_inbound_group_session(sessionPtr, sessionKeyPtr, sessionKeyLength); sessionResult = olm_init_inbound_group_session(sessionPtr, sessionKeyPtr, sessionKeyLength);
if(sessionResult == olm_error()) { if(sessionResult == olm_error()) {
...@@ -116,7 +116,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes ...@@ -116,7 +116,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
else else
{ {
retCode = ERROR_CODE_OK; retCode = ERROR_CODE_OK;
LOGD(" ## initInboundSessionFromIdKeyJni(): success - result=%lu", sessionResult); LOGD(" ## initInboundSessionFromIdKeyJni(): success - result=%lu", static_cast<long unsigned int>(sessionResult));
} }
} }
...@@ -149,7 +149,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn ...@@ -149,7 +149,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn
{ {
// get the size to alloc // get the size to alloc
size_t lengthSessionId = olm_inbound_group_session_id_length(sessionPtr); size_t lengthSessionId = olm_inbound_group_session_id_length(sessionPtr);
LOGD(" ## sessionIdentifierJni(): inbound group session lengthSessionId=%lu",lengthSessionId); LOGD(" ## sessionIdentifierJni(): inbound group session lengthSessionId=%lu",static_cast<long unsigned int>(lengthSessionId));
if(NULL == (sessionIdPtr = (uint8_t*)malloc((lengthSessionId+1)*sizeof(uint8_t)))) if(NULL == (sessionIdPtr = (uint8_t*)malloc((lengthSessionId+1)*sizeof(uint8_t))))
{ {
...@@ -166,7 +166,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn ...@@ -166,7 +166,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn
{ {
// update length // update length
sessionIdPtr[result] = static_cast<char>('\0'); sessionIdPtr[result] = static_cast<char>('\0');
LOGD(" ## sessionIdentifierJni(): success - inbound group session result=%lu sessionId=%s",result, (char*)sessionIdPtr); LOGD(" ## sessionIdentifierJni(): success - inbound group session result=%lu sessionId=%s",static_cast<long unsigned int>(result), (char*)sessionIdPtr);
returnValueStr = env->NewStringUTF((const char*)sessionIdPtr); returnValueStr = env->NewStringUTF((const char*)sessionIdPtr);
} }
free(sessionIdPtr); free(sessionIdPtr);
...@@ -212,7 +212,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv * ...@@ -212,7 +212,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
else else
{ {
memcpy(tempEncryptedPtr, encryptedMsgPtr, encryptedMsgLength); memcpy(tempEncryptedPtr, encryptedMsgPtr, encryptedMsgLength);
LOGD(" ## decryptMessageJni(): encryptedMsgLength=%lu encryptedMsg=%s",encryptedMsgLength,encryptedMsgPtr); LOGD(" ## decryptMessageJni(): encryptedMsgLength=%lu encryptedMsg=%s",static_cast<long unsigned int>(encryptedMsgLength),encryptedMsgPtr);
// get max plaintext length // get max plaintext length
size_t maxPlainTextLength = olm_group_decrypt_max_plaintext_length(sessionPtr, size_t maxPlainTextLength = olm_group_decrypt_max_plaintext_length(sessionPtr,
...@@ -224,7 +224,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv * ...@@ -224,7 +224,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
} }
else else
{ {
LOGD(" ## decryptMessageJni(): maxPlaintextLength=%lu",maxPlainTextLength); LOGD(" ## decryptMessageJni(): maxPlaintextLength=%lu",static_cast<long unsigned int>(maxPlainTextLength));
// allocate output decrypted message // allocate output decrypted message
plainTextMsgPtr = static_cast<uint8_t*>(malloc((maxPlainTextLength+1)*sizeof(uint8_t))); plainTextMsgPtr = static_cast<uint8_t*>(malloc((maxPlainTextLength+1)*sizeof(uint8_t)));
...@@ -245,7 +245,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv * ...@@ -245,7 +245,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
// update decrypted buffer size // update decrypted buffer size
plainTextMsgPtr[plaintextLength] = static_cast<char>('\0'); plainTextMsgPtr[plaintextLength] = static_cast<char>('\0');
LOGD(" ## decryptMessageJni(): decrypted returnedLg=%lu plainTextMsgPtr=%s",plaintextLength, (char*)plainTextMsgPtr); LOGD(" ## decryptMessageJni(): decrypted returnedLg=%lu plainTextMsgPtr=%s",static_cast<long unsigned int>(plaintextLength), (char*)plainTextMsgPtr);
decryptedMsgRetValue = env->NewStringUTF((const char*)plainTextMsgPtr); decryptedMsgRetValue = env->NewStringUTF((const char*)plainTextMsgPtr);
} }
} }
...@@ -318,7 +318,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN ...@@ -318,7 +318,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
{ {
size_t pickledLength = olm_pickle_inbound_group_session_length(sessionPtr); size_t pickledLength = olm_pickle_inbound_group_session_length(sessionPtr);
size_t keyLength = (size_t)env->GetStringUTFLength(aKey); size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",pickledLength, keyLength); LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu", static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t)))) if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t))))
...@@ -347,7 +347,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN ...@@ -347,7 +347,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
// build success output // build success output
(static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0');
pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr);
LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", result, static_cast<char*>(pickledPtr)); LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr));
} }
} }
} }
...@@ -400,7 +400,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)( ...@@ -400,7 +400,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
{ {
size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData); size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
size_t keyLength = (size_t)env->GetStringUTFLength(aKey); size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",pickledLength, keyLength); LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
...@@ -417,7 +417,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)( ...@@ -417,7 +417,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
} }
else else
{ {
LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", result); LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result));
} }
} }
......
...@@ -28,12 +28,18 @@ ...@@ -28,12 +28,18 @@
#define TAG "OlmJniNative" #define TAG "OlmJniNative"
/* logging macros */ /* logging macros */
#define ENABLE_LOGS //#define ENABLE_LOGS
#ifdef NDK_DEBUG
#warning "NDK_DEBUG is defined"
#else
#warning "NDK_DEBUG not defined"
#endif
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
#ifdef ENABLE_LOGS #ifdef NDK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#else #else
......
...@@ -45,15 +45,12 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize) ...@@ -45,15 +45,12 @@ bool setRandomInBuffer(uint8_t **aBuffer2Ptr, size_t aRandomSize)
} }
else else
{ {
LOGD("## setRandomInBuffer(): randomSize=%ld",aRandomSize); LOGD("## setRandomInBuffer(): randomSize=%lu",static_cast<long unsigned int>(aRandomSize));
srand(time(NULL)); // init seed srand(time(NULL)); // init seed
for(size_t i=0;i<aRandomSize;i++) for(size_t i=0;i<aRandomSize;i++)
{ {
(*aBuffer2Ptr)[i] = (uint8_t)(rand()%ACCOUNT_CREATION_RANDOM_MODULO); (*aBuffer2Ptr)[i] = (uint8_t)(rand()%ACCOUNT_CREATION_RANDOM_MODULO);
// debug purpose
//LOGD("## setRandomInBuffer(): randomBuffPtr[%ld]=%d",i, (*aBuffer2Ptr)[i]);
} }
retCode = true; retCode = true;
...@@ -220,7 +217,7 @@ jstring serializeDataWithKey(JNIEnv *env, jobject thiz, ...@@ -220,7 +217,7 @@ jstring serializeDataWithKey(JNIEnv *env, jobject thiz,
{ {
size_t pickledLength = aGetLengthFunc(accountPtr); size_t pickledLength = aGetLengthFunc(accountPtr);
size_t keyLength = (size_t)env->GetStringUTFLength(aKey); size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",pickledLength, keyLength); LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t)))) if(NULL == (pickledPtr = (void*)malloc((pickledLength+1)*sizeof(uint8_t))))
...@@ -249,7 +246,7 @@ jstring serializeDataWithKey(JNIEnv *env, jobject thiz, ...@@ -249,7 +246,7 @@ jstring serializeDataWithKey(JNIEnv *env, jobject thiz,
// build success output // build success output
(static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0');
pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr);
LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", result, static_cast<char*>(pickledPtr)); LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr));
} }
} }
} }
......
...@@ -27,7 +27,7 @@ JNIEXPORT void OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *en ...@@ -27,7 +27,7 @@ JNIEXPORT void OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *en
{ {
OlmOutboundGroupSession* sessionPtr = NULL; OlmOutboundGroupSession* sessionPtr = NULL;
LOGD("## releaseSessionJni(): outbound group session"); LOGD("## releaseSessionJni(): OutBound group session IN");
if(NULL == (sessionPtr = (OlmOutboundGroupSession*)getOutboundGroupSessionInstanceId(env,thiz))) if(NULL == (sessionPtr = (OlmOutboundGroupSession*)getOutboundGroupSessionInstanceId(env,thiz)))
{ {
...@@ -38,7 +38,7 @@ JNIEXPORT void OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *en ...@@ -38,7 +38,7 @@ JNIEXPORT void OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *en
LOGD(" ## releaseSessionJni(): sessionPtr=%p",sessionPtr); LOGD(" ## releaseSessionJni(): sessionPtr=%p",sessionPtr);
size_t retCode = olm_clear_outbound_group_session(sessionPtr); size_t retCode = olm_clear_outbound_group_session(sessionPtr);
LOGI(" ## releaseSessionJni(): clear_outbound_group_session=%lu",retCode); LOGI(" ## releaseSessionJni(): clear_outbound_group_session=%lu",static_cast<long unsigned int>(retCode));
LOGD(" ## releaseSessionJni(): free IN"); LOGD(" ## releaseSessionJni(): free IN");
free(sessionPtr); free(sessionPtr);
...@@ -67,7 +67,7 @@ JNIEXPORT jlong OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv ...@@ -67,7 +67,7 @@ JNIEXPORT jlong OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv
else if(NULL != (sessionPtr=(OlmOutboundGroupSession*)malloc(sessionSize))) else if(NULL != (sessionPtr=(OlmOutboundGroupSession*)malloc(sessionSize)))
{ {
sessionPtr = olm_outbound_group_session(sessionPtr); sessionPtr = olm_outbound_group_session(sessionPtr);
LOGD(" ## createNewSessionJni(): success - outbound group session size=%lu",sessionSize); LOGD(" ## createNewSessionJni(): success - outbound group session size=%lu",static_cast<long unsigned int>(sessionSize));
} }
else else
{ {
...@@ -97,7 +97,7 @@ JNIEXPORT jint OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initOutboundGroupSessionJni)( ...@@ -97,7 +97,7 @@ JNIEXPORT jint OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initOutboundGroupSessionJni)(
{ {
// compute random buffer // compute random buffer
size_t randomLength = olm_init_outbound_group_session_random_length(sessionPtr); size_t randomLength = olm_init_outbound_group_session_random_length(sessionPtr);
LOGW(" ## initOutboundGroupSessionJni(): randomLength=%lu",randomLength); LOGW(" ## initOutboundGroupSessionJni(): randomLength=%lu",static_cast<long unsigned int>(randomLength));
if((0!=randomLength) && !setRandomInBuffer(&randomBuffPtr, randomLength)) if((0!=randomLength) && !setRandomInBuffer(&randomBuffPtr, randomLength))
{ {
LOGE(" ## initOutboundGroupSessionJni(): failure - random buffer init"); LOGE(" ## initOutboundGroupSessionJni(): failure - random buffer init");
...@@ -116,7 +116,7 @@ JNIEXPORT jint OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initOutboundGroupSessionJni)( ...@@ -116,7 +116,7 @@ JNIEXPORT jint OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initOutboundGroupSessionJni)(
else else
{ {
retCode = ERROR_CODE_OK; retCode = ERROR_CODE_OK;
LOGD(" ## initOutboundGroupSessionJni(): success - result=%lu", sessionResult); LOGD(" ## initOutboundGroupSessionJni(): success - result=%lu", static_cast<long unsigned int>(sessionResult));
} }
} }
} }
...@@ -148,7 +148,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIE ...@@ -148,7 +148,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIE
{ {
// get the size to alloc // get the size to alloc
size_t lengthSessionId = olm_outbound_group_session_id_length(sessionPtr); size_t lengthSessionId = olm_outbound_group_session_id_length(sessionPtr);
LOGD(" ## sessionIdentifierJni(): outbound group session lengthSessionId=%lu",lengthSessionId); LOGD(" ## sessionIdentifierJni(): outbound group session lengthSessionId=%lu",static_cast<long unsigned int>(lengthSessionId));
if(NULL == (sessionIdPtr = (uint8_t*)malloc((lengthSessionId+1)*sizeof(uint8_t)))) if(NULL == (sessionIdPtr = (uint8_t*)malloc((lengthSessionId+1)*sizeof(uint8_t))))
{ {
...@@ -159,13 +159,13 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIE ...@@ -159,13 +159,13 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIE
size_t result = olm_outbound_group_session_id(sessionPtr, sessionIdPtr, lengthSessionId); size_t result = olm_outbound_group_session_id(sessionPtr, sessionIdPtr, lengthSessionId);
if (result == olm_error()) if (result == olm_error())
{ {
LOGE(" ## sessionIdentifierJni(): failure - outbound group session identifier failure Msg=%s",(const char *)olm_outbound_group_session_last_error(sessionPtr)); LOGE(" ## sessionIdentifierJni(): failure - outbound group session identifier failure Msg=%s",reinterpret_cast<const char*>(olm_outbound_group_session_last_error(sessionPtr)));
} }
else else
{ {
// update length // update length
sessionIdPtr[result] = static_cast<char>('\0'); sessionIdPtr[result] = static_cast<char>('\0');
LOGD(" ## sessionIdentifierJni(): success - outbound group session identifier result=%lu sessionId=%s",result, (char*)sessionIdPtr); LOGD(" ## sessionIdentifierJni(): success - outbound group session identifier result=%lu sessionId=%s",static_cast<long unsigned int>(result), reinterpret_cast<char*>(sessionIdPtr));
returnValueStr = env->NewStringUTF((const char*)sessionIdPtr); returnValueStr = env->NewStringUTF((const char*)sessionIdPtr);
} }
...@@ -224,7 +224,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env ...@@ -224,7 +224,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env
{ {
// get the size to alloc // get the size to alloc
size_t sessionKeyLength = olm_outbound_group_session_key_length(sessionPtr); size_t sessionKeyLength = olm_outbound_group_session_key_length(sessionPtr);
LOGD(" ## sessionKeyJni(): sessionKeyLength=%lu",sessionKeyLength); LOGD(" ## sessionKeyJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength));
if(NULL == (sessionKeyPtr = (uint8_t*)malloc((sessionKeyLength+1)*sizeof(uint8_t)))) if(NULL == (sessionKeyPtr = (uint8_t*)malloc((sessionKeyLength+1)*sizeof(uint8_t))))
{ {
...@@ -241,7 +241,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env ...@@ -241,7 +241,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env