Fix warnings detected on Android build
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
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 1ccfe67..caa9b47 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -942,11 +942,6 @@ static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
}
}
-static SDL_bool LocalReferenceHolder_IsActive(void)
-{
- return s_active > 0;
-}
-
ANativeWindow* Android_JNI_GetNativeWindow(void)
{
ANativeWindow* anw;
@@ -1372,7 +1367,8 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
JNIEnv *mEnv = Android_JNI_GetEnv();
jthrowable exception;
- SDL_assert(LocalReferenceHolder_IsActive());
+ /* Detect mismatch LocalReferenceHolder_Init/Cleanup */
+ SDL_assert((s_active > 0));
exception = (*mEnv)->ExceptionOccurred(mEnv);
if (exception != NULL) {
@@ -1455,13 +1451,13 @@ static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
}
mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
- ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+ ctx->hidden.androidio.offset = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
goto fallback;
}
mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
- ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid);
+ ctx->hidden.androidio.size = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
goto fallback;
}
@@ -1779,7 +1775,7 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
if (amount > movement) {
amount = movement;
}
- result = Android_JNI_FileRead(ctx, buffer, 1, amount);
+ result = Android_JNI_FileRead(ctx, buffer, 1, (size_t)amount);
if (result <= 0) {
/* Failed to read/skip the required amount, so fail */
return -1;
diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c
index 69b657f..a4a85ab 100644
--- a/src/joystick/android/SDL_sysjoystick.c
+++ b/src/joystick/android/SDL_sysjoystick.c
@@ -83,7 +83,7 @@ static Uint32 crc32_for_byte(Uint32 r)
return r ^ (Uint32)0xFF000000L;
}
-static Uint32 crc32(const void *data, int count)
+static Uint32 crc32(const void *data, size_t count)
{
Uint32 crc = 0;
int i;
diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c
index 5045996..c79866d 100644
--- a/src/timer/unix/SDL_systimer.c
+++ b/src/timer/unix/SDL_systimer.c
@@ -112,8 +112,7 @@ SDL_GetTicks(void)
#if HAVE_CLOCK_GETTIME
struct timespec now;
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
- ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
- start_ts.tv_nsec) / 1000000;
+ ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
#elif defined(__APPLE__)
uint64_t now = mach_absolute_time();
ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);