Fix warnings detected on Android build
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 06 Dec 2018 15:46:40 +0100
changeset 12464db15b3c90139
parent 12463 fb8dac9fbc5e
child 12465 1f85fce42a31
Fix warnings detected on Android build
src/core/android/SDL_android.c
src/joystick/android/SDL_sysjoystick.c
src/timer/unix/SDL_systimer.c
     1.1 --- a/src/core/android/SDL_android.c	Thu Dec 06 10:24:44 2018 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Thu Dec 06 15:46:40 2018 +0100
     1.3 @@ -942,11 +942,6 @@
     1.4      }
     1.5  }
     1.6  
     1.7 -static SDL_bool LocalReferenceHolder_IsActive(void)
     1.8 -{
     1.9 -    return s_active > 0;
    1.10 -}
    1.11 -
    1.12  ANativeWindow* Android_JNI_GetNativeWindow(void)
    1.13  {
    1.14      ANativeWindow* anw;
    1.15 @@ -1372,7 +1367,8 @@
    1.16      JNIEnv *mEnv = Android_JNI_GetEnv();
    1.17      jthrowable exception;
    1.18  
    1.19 -    SDL_assert(LocalReferenceHolder_IsActive());
    1.20 +    /* Detect mismatch LocalReferenceHolder_Init/Cleanup */
    1.21 +    SDL_assert((s_active > 0));
    1.22  
    1.23      exception = (*mEnv)->ExceptionOccurred(mEnv);
    1.24      if (exception != NULL) {
    1.25 @@ -1455,13 +1451,13 @@
    1.26      }
    1.27  
    1.28      mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
    1.29 -    ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.30 +    ctx->hidden.androidio.offset = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.31      if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
    1.32          goto fallback;
    1.33      }
    1.34  
    1.35      mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
    1.36 -    ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.37 +    ctx->hidden.androidio.size = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
    1.38      if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
    1.39          goto fallback;
    1.40      }
    1.41 @@ -1779,7 +1775,7 @@
    1.42                  if (amount > movement) {
    1.43                      amount = movement;
    1.44                  }
    1.45 -                result = Android_JNI_FileRead(ctx, buffer, 1, amount);
    1.46 +                result = Android_JNI_FileRead(ctx, buffer, 1, (size_t)amount);
    1.47                  if (result <= 0) {
    1.48                      /* Failed to read/skip the required amount, so fail */
    1.49                      return -1;
     2.1 --- a/src/joystick/android/SDL_sysjoystick.c	Thu Dec 06 10:24:44 2018 +0100
     2.2 +++ b/src/joystick/android/SDL_sysjoystick.c	Thu Dec 06 15:46:40 2018 +0100
     2.3 @@ -83,7 +83,7 @@
     2.4      return r ^ (Uint32)0xFF000000L;
     2.5  }
     2.6  
     2.7 -static Uint32 crc32(const void *data, int count)
     2.8 +static Uint32 crc32(const void *data, size_t count)
     2.9  {
    2.10      Uint32 crc = 0;
    2.11      int i;
     3.1 --- a/src/timer/unix/SDL_systimer.c	Thu Dec 06 10:24:44 2018 +0100
     3.2 +++ b/src/timer/unix/SDL_systimer.c	Thu Dec 06 15:46:40 2018 +0100
     3.3 @@ -112,8 +112,7 @@
     3.4  #if HAVE_CLOCK_GETTIME
     3.5          struct timespec now;
     3.6          clock_gettime(SDL_MONOTONIC_CLOCK, &now);
     3.7 -        ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
     3.8 -                                                 start_ts.tv_nsec) / 1000000;
     3.9 +        ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
    3.10  #elif defined(__APPLE__)
    3.11          uint64_t now = mach_absolute_time();
    3.12          ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);