Android: some readability: redundant casts, deads stores, redundant control flow
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 31 Oct 2019 15:53:10 +0100
changeset 13226294f9fc96e56
parent 13225 0e512800c68c
child 13228 50a9f9c538c5
Android: some readability: redundant casts, deads stores, redundant control flow
src/core/android/SDL_android.c
src/video/android/SDL_androidtouch.c
src/video/android/SDL_androidvulkan.c
     1.1 --- a/src/core/android/SDL_android.c	Thu Oct 31 17:10:02 2019 +0300
     1.2 +++ b/src/core/android/SDL_android.c	Thu Oct 31 15:53:10 2019 +0100
     1.3 @@ -1311,7 +1311,7 @@
     1.4  {
     1.5      JNIEnv *env = Android_JNI_GetEnv();
     1.6  
     1.7 -    jstring jtitle = (jstring)((*env)->NewStringUTF(env, title));
     1.8 +    jstring jtitle = (*env)->NewStringUTF(env, title);
     1.9      (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetActivityTitle, jtitle);
    1.10      (*env)->DeleteLocalRef(env, jtitle);
    1.11  }
    1.12 @@ -1326,7 +1326,7 @@
    1.13  {
    1.14      JNIEnv *env = Android_JNI_GetEnv();
    1.15  
    1.16 -    jstring jhint = (jstring)((*env)->NewStringUTF(env, (hint ? hint : "")));
    1.17 +    jstring jhint = (*env)->NewStringUTF(env, (hint ? hint : ""));
    1.18      (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
    1.19      (*env)->DeleteLocalRef(env, jhint);
    1.20  }
    1.21 @@ -1371,7 +1371,6 @@
    1.22  int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
    1.23  {
    1.24      int audioformat;
    1.25 -    int numBufferFrames;
    1.26      jobject jbufobj = NULL;
    1.27      jobject result;
    1.28      int *resultElements;
    1.29 @@ -1476,7 +1475,6 @@
    1.30          audioBufferFormat = audioformat;
    1.31          audioBuffer = jbufobj;
    1.32      }
    1.33 -    numBufferFrames = (*env)->GetArrayLength(env, (jarray)jbufobj);
    1.34  
    1.35      if (!iscapture) {
    1.36          isCopy = JNI_FALSE;
    1.37 @@ -1578,7 +1576,7 @@
    1.38          if (br > 0) {
    1.39              jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy);
    1.40              SDL_memcpy(buffer, ptr, br);
    1.41 -            (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT);
    1.42 +            (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, ptr, JNI_ABORT);
    1.43          }
    1.44          break;
    1.45      case ENCODING_PCM_16BIT:
    1.46 @@ -1588,7 +1586,7 @@
    1.47              jshort *ptr = (*env)->GetShortArrayElements(env, (jshortArray)captureBuffer, &isCopy);
    1.48              br *= sizeof(Sint16);
    1.49              SDL_memcpy(buffer, ptr, br);
    1.50 -            (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, (jshort *)ptr, JNI_ABORT);
    1.51 +            (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, ptr, JNI_ABORT);
    1.52          }
    1.53          break;
    1.54      case ENCODING_PCM_FLOAT:
    1.55 @@ -1598,7 +1596,7 @@
    1.56              jfloat *ptr = (*env)->GetFloatArrayElements(env, (jfloatArray)captureBuffer, &isCopy);
    1.57              br *= sizeof(float);
    1.58              SDL_memcpy(buffer, ptr, br);
    1.59 -            (*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, (jfloat *)ptr, JNI_ABORT);
    1.60 +            (*env)->ReleaseFloatArrayElements(env, (jfloatArray)captureBuffer, ptr, JNI_ABORT);
    1.61          }
    1.62          break;
    1.63      default:
    1.64 @@ -2052,7 +2050,6 @@
    1.65              default:
    1.66                  return SDL_SetError("Unknown value for 'whence'");
    1.67          }
    1.68 -        whence = SEEK_SET;
    1.69  
    1.70          ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET);
    1.71          if (ret == -1) return -1;
    1.72 @@ -2508,7 +2505,6 @@
    1.73  {
    1.74      JNIEnv *env = Android_JNI_GetEnv();
    1.75      (*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton);
    1.76 -    return;
    1.77  }
    1.78  
    1.79  const char * SDL_AndroidGetInternalStoragePath(void)
     2.1 --- a/src/video/android/SDL_androidtouch.c	Thu Oct 31 17:10:02 2019 +0300
     2.2 +++ b/src/video/android/SDL_androidtouch.c	Thu Oct 31 15:53:10 2019 +0100
     2.3 @@ -48,7 +48,6 @@
     2.4  
     2.5  void Android_QuitTouch(void)
     2.6  {
     2.7 -    return;
     2.8  }
     2.9  
    2.10  void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
     3.1 --- a/src/video/android/SDL_androidvulkan.c	Thu Oct 31 17:10:02 2019 +0300
     3.2 +++ b/src/video/android/SDL_androidvulkan.c	Thu Oct 31 15:53:10 2019 +0100
     3.3 @@ -137,7 +137,7 @@
     3.4          (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
     3.5      PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =
     3.6          (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(
     3.7 -                                            (VkInstance)instance,
     3.8 +                                            instance,
     3.9                                              "vkCreateAndroidSurfaceKHR");
    3.10      VkAndroidSurfaceCreateInfoKHR createInfo;
    3.11      VkResult result;