From 303646a69766281244212d81e89fc3d9a34d7118 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 31 Oct 2019 15:53:10 +0100 Subject: [PATCH] Android: some readability: redundant casts, deads stores, redundant control flow --- src/core/android/SDL_android.c | 14 +++++--------- src/video/android/SDL_androidtouch.c | 1 - src/video/android/SDL_androidvulkan.c | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 26bcd555c6765..044859d538abb 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -1311,7 +1311,7 @@ void Android_JNI_SetActivityTitle(const char *title) { JNIEnv *env = Android_JNI_GetEnv(); - jstring jtitle = (jstring)((*env)->NewStringUTF(env, title)); + jstring jtitle = (*env)->NewStringUTF(env, title); (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetActivityTitle, jtitle); (*env)->DeleteLocalRef(env, jtitle); } @@ -1326,7 +1326,7 @@ void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint) { JNIEnv *env = Android_JNI_GetEnv(); - jstring jhint = (jstring)((*env)->NewStringUTF(env, (hint ? hint : ""))); + jstring jhint = (*env)->NewStringUTF(env, (hint ? hint : "")); (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint); (*env)->DeleteLocalRef(env, jhint); } @@ -1371,7 +1371,6 @@ static jobject captureBuffer = NULL; int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) { int audioformat; - int numBufferFrames; jobject jbufobj = NULL; jobject result; int *resultElements; @@ -1476,7 +1475,6 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec) audioBufferFormat = audioformat; audioBuffer = jbufobj; } - numBufferFrames = (*env)->GetArrayLength(env, (jarray)jbufobj); if (!iscapture) { isCopy = JNI_FALSE; @@ -1578,7 +1576,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen) if (br > 0) { jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy); SDL_memcpy(buffer, ptr, br); - (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT); + (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, ptr, JNI_ABORT); } break; case ENCODING_PCM_16BIT: @@ -1588,7 +1586,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen) jshort *ptr = (*env)->GetShortArrayElements(env, (jshortArray)captureBuffer, &isCopy); br *= sizeof(Sint16); SDL_memcpy(buffer, ptr, br); - (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, (jshort *)ptr, JNI_ABORT); + (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, ptr, JNI_ABORT); } break; case ENCODING_PCM_FLOAT: @@ -1598,7 +1596,7 @@ int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen) jfloat *ptr = (*env)->GetFloatArrayElements(env, (jfloatArray)captureBuffer, &isCopy); br *= sizeof(float); SDL_memcpy(buffer, ptr, br); - (*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, (jfloat *)ptr, JNI_ABORT); + (*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, ptr, JNI_ABORT); } break; default: @@ -2052,7 +2050,6 @@ Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence) default: return SDL_SetError("Unknown value for 'whence'"); } - whence = SEEK_SET; ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET); if (ret == -1) return -1; @@ -2508,7 +2505,6 @@ void SDL_AndroidBackButton(void) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton); - return; } const char * SDL_AndroidGetInternalStoragePath(void) diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 063e7b3c46894..26dd15c49c03d 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -48,7 +48,6 @@ void Android_InitTouch(void) void Android_QuitTouch(void) { - return; } void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index f1a5e7e506b62..b7d2561ce8e3a 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -137,7 +137,7 @@ SDL_bool Android_Vulkan_CreateSurface(_THIS, (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr( - (VkInstance)instance, + instance, "vkCreateAndroidSurfaceKHR"); VkAndroidSurfaceCreateInfoKHR createInfo; VkResult result;