From 357493082fb9b6b7e66f05394db839da761bbb29 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 23 Jul 2019 17:21:09 +0100 Subject: ANDROID: Fix some Codacy warnings --- backends/platform/android/android.cpp | 11 ++++------- backends/platform/android/jni.cpp | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'backends/platform/android') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 4f1b852d26..f3dc0b5876 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -231,9 +231,7 @@ void *OSystem_Android::audioThreadFunc(void *arg) { bool paused = true; - byte *buf; - int offset, left, written; - int samples, i; + int offset, left, written, i; struct timespec tv_delay; tv_delay.tv_sec = 0; @@ -245,7 +243,6 @@ void *OSystem_Android::audioThreadFunc(void *arg) { tv_full.tv_sec = 0; tv_full.tv_nsec = msecs_full * 1000 * 1000; - bool silence; uint silence_count = 33; while (!system->_audio_thread_exit) { @@ -260,12 +257,12 @@ void *OSystem_Android::audioThreadFunc(void *arg) { LOGD("audio thread woke up"); } - buf = (byte *)env->GetPrimitiveArrayCritical(bufa, 0); + byte *buf = (byte *)env->GetPrimitiveArrayCritical(bufa, 0); assert(buf); - samples = mixer->mixCallback(buf, buf_size); + int samples = mixer->mixCallback(buf, buf_size); - silence = samples < 1; + bool silence = samples < 1; // looks stupid, and it is, but currently there's no way to detect // silence-only buffers from the mixer diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index 47dd5c73cf..ffe60062fb 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -260,9 +260,8 @@ bool JNI::openUrl(const char *url) { } bool JNI::hasTextInClipboard() { - bool hasText = false; JNIEnv *env = JNI::getEnv(); - hasText = env->CallBooleanMethod(_jobj, _MID_hasTextInClipboard); + bool hasText = env->CallBooleanMethod(_jobj, _MID_hasTextInClipboard); if (env->ExceptionCheck()) { LOGE("Failed to check the contents of the clipboard"); @@ -299,13 +298,12 @@ Common::String JNI::getTextFromClipboard() { } bool JNI::setTextInClipboard(const Common::String &text) { - bool success = true; JNIEnv *env = JNI::getEnv(); jbyteArray javaText = env->NewByteArray(text.size()); env->SetByteArrayRegion(javaText, 0, text.size(), reinterpret_cast(text.c_str())); - success = env->CallBooleanMethod(_jobj, _MID_setTextInClipboard, javaText); + bool success = env->CallBooleanMethod(_jobj, _MID_setTextInClipboard, javaText); if (env->ExceptionCheck()) { LOGE("Failed to add text to the clipboard"); @@ -320,9 +318,8 @@ bool JNI::setTextInClipboard(const Common::String &text) { } bool JNI::isConnectionLimited() { - bool limited = false; JNIEnv *env = JNI::getEnv(); - limited = env->CallBooleanMethod(_jobj, _MID_isConnectionLimited); + bool limited = env->CallBooleanMethod(_jobj, _MID_isConnectionLimited); if (env->ExceptionCheck()) { LOGE("Failed to check whether connection's limited"); -- cgit v1.2.3