Android: some readability: redundant casts, deads stores, redundant control flow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 26bcd55..044859d 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 063e7b3..26dd15c 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 f1a5e7e..b7d2561 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;