Android: C89 cleanup to avoid warnings/errors since the default gcc mode on Android is still pre-C99.
authorEric Wing <ewing . public |-at-| gmail . com>
Tue, 09 Feb 2016 17:36:42 -0800
changeset 10080426de7645465
parent 10063 c5e3a4f88be9
child 10081 a858fbc2e1f8
Android: C89 cleanup to avoid warnings/errors since the default gcc mode on Android is still pre-C99.
src/core/android/SDL_android.c
src/joystick/android/SDL_sysjoystick.c
src/main/android/SDL_android_main.c
     1.1 --- a/src/core/android/SDL_android.c	Mon Feb 08 01:08:21 2016 -0500
     1.2 +++ b/src/core/android/SDL_android.c	Tue Feb 09 17:36:42 2016 -0800
     1.3 @@ -561,6 +561,7 @@
     1.4  {
     1.5      jboolean audioBufferStereo;
     1.6      int audioBufferFrames;
     1.7 +    jboolean isCopy;
     1.8  
     1.9      JNIEnv *env = Android_JNI_GetEnv();
    1.10  
    1.11 @@ -602,7 +603,7 @@
    1.12          return 0;
    1.13      }
    1.14  
    1.15 -    jboolean isCopy = JNI_FALSE;
    1.16 +    isCopy = JNI_FALSE;
    1.17      if (audioBuffer16Bit) {
    1.18          audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
    1.19          audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
    1.20 @@ -654,10 +655,12 @@
    1.21  /* If the parameter silent is truthy then SDL_SetError() will not be called. */
    1.22  static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
    1.23  {
    1.24 +    JNIEnv *mEnv = Android_JNI_GetEnv();
    1.25 +    jthrowable exception;
    1.26 +
    1.27      SDL_assert(LocalReferenceHolder_IsActive());
    1.28 -    JNIEnv *mEnv = Android_JNI_GetEnv();
    1.29  
    1.30 -    jthrowable exception = (*mEnv)->ExceptionOccurred(mEnv);
    1.31 +    exception = (*mEnv)->ExceptionOccurred(mEnv);
    1.32      if (exception != NULL) {
    1.33          jmethodID mid;
    1.34  
    1.35 @@ -667,13 +670,16 @@
    1.36          if (!silent) {
    1.37              jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception);
    1.38              jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class");
    1.39 +            jstring exceptionName;
    1.40 +            const char* exceptionNameUTF8;
    1.41 +            jstring exceptionMessage;
    1.42  
    1.43              mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;");
    1.44 -            jstring exceptionName = (jstring)(*mEnv)->CallObjectMethod(mEnv, exceptionClass, mid);
    1.45 -            const char* exceptionNameUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionName, 0);
    1.46 +            exceptionName = (jstring)(*mEnv)->CallObjectMethod(mEnv, exceptionClass, mid);
    1.47 +            exceptionNameUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionName, 0);
    1.48  
    1.49              mid = (*mEnv)->GetMethodID(mEnv, exceptionClass, "getMessage", "()Ljava/lang/String;");
    1.50 -            jstring exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid);
    1.51 +            exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid);
    1.52  
    1.53              if (exceptionMessage != NULL) {
    1.54                  const char* exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0);
    1.55 @@ -856,6 +862,7 @@
    1.56      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
    1.57      JNIEnv *mEnv = Android_JNI_GetEnv();
    1.58      int retval;
    1.59 +    jstring fileNameJString;
    1.60  
    1.61      if (!LocalReferenceHolder_Init(&refs, mEnv)) {
    1.62          LocalReferenceHolder_Cleanup(&refs);        
    1.63 @@ -867,7 +874,7 @@
    1.64          return -1;
    1.65      }
    1.66  
    1.67 -    jstring fileNameJString = (*mEnv)->NewStringUTF(mEnv, fileName);
    1.68 +    fileNameJString = (*mEnv)->NewStringUTF(mEnv, fileName);
    1.69      ctx->hidden.androidio.fileNameRef = (*mEnv)->NewGlobalRef(mEnv, fileNameJString);
    1.70      ctx->hidden.androidio.inputStreamRef = NULL;
    1.71      ctx->hidden.androidio.readableByteChannelRef = NULL;
    1.72 @@ -886,10 +893,11 @@
    1.73  
    1.74      if (ctx->hidden.androidio.assetFileDescriptorRef) {
    1.75          size_t bytesMax = size * maxnum;
    1.76 +        size_t result;
    1.77          if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) {
    1.78              bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position;
    1.79          }
    1.80 -        size_t result = read(ctx->hidden.androidio.fd, buffer, bytesMax );
    1.81 +        result = read(ctx->hidden.androidio.fd, buffer, bytesMax );
    1.82          if (result > 0) {
    1.83              ctx->hidden.androidio.position += result;
    1.84              LocalReferenceHolder_Cleanup(&refs);
    1.85 @@ -901,19 +909,23 @@
    1.86          jlong bytesRemaining = (jlong) (size * maxnum);
    1.87          jlong bytesMax = (jlong) (ctx->hidden.androidio.size -  ctx->hidden.androidio.position);
    1.88          int bytesRead = 0;
    1.89 +        JNIEnv *mEnv;
    1.90 +        jobject readableByteChannel;
    1.91 +        jmethodID readMethod;
    1.92 +        jobject byteBuffer;
    1.93  
    1.94          /* Don't read more bytes than those that remain in the file, otherwise we get an exception */
    1.95          if (bytesRemaining >  bytesMax) bytesRemaining = bytesMax;
    1.96  
    1.97 -        JNIEnv *mEnv = Android_JNI_GetEnv();
    1.98 +        mEnv = Android_JNI_GetEnv();
    1.99          if (!LocalReferenceHolder_Init(&refs, mEnv)) {
   1.100              LocalReferenceHolder_Cleanup(&refs);            
   1.101              return 0;
   1.102          }
   1.103  
   1.104 -        jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
   1.105 -        jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
   1.106 -        jobject byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining);
   1.107 +        readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
   1.108 +        readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
   1.109 +        byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining);
   1.110  
   1.111          while (bytesRemaining > 0) {
   1.112              /* result = readableByteChannel.read(...); */
   1.113 @@ -1003,6 +1015,7 @@
   1.114  Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
   1.115  {
   1.116      if (ctx->hidden.androidio.assetFileDescriptorRef) {
   1.117 +        off_t ret;
   1.118          switch (whence) {
   1.119              case RW_SEEK_SET:
   1.120                  if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size;
   1.121 @@ -1021,11 +1034,12 @@
   1.122          }
   1.123          whence = SEEK_SET;
   1.124  
   1.125 -        off_t ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET);
   1.126 +        ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET);
   1.127          if (ret == -1) return -1;
   1.128          ctx->hidden.androidio.position = ret - ctx->hidden.androidio.offset;
   1.129      } else {
   1.130          Sint64 newPosition;
   1.131 +        Sint64 movement;
   1.132  
   1.133          switch (whence) {
   1.134              case RW_SEEK_SET:
   1.135 @@ -1049,17 +1063,18 @@
   1.136              newPosition = ctx->hidden.androidio.size;
   1.137          }
   1.138  
   1.139 -        Sint64 movement = newPosition - ctx->hidden.androidio.position;
   1.140 +        movement = newPosition - ctx->hidden.androidio.position;
   1.141          if (movement > 0) {
   1.142              unsigned char buffer[4096];
   1.143  
   1.144              /* The easy case where we're seeking forwards */
   1.145              while (movement > 0) {
   1.146                  Sint64 amount = sizeof (buffer);
   1.147 +                size_t result;
   1.148                  if (amount > movement) {
   1.149                      amount = movement;
   1.150                  }
   1.151 -                size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount);
   1.152 +                result = Android_JNI_FileRead(ctx, buffer, 1, amount);
   1.153                  if (result <= 0) {
   1.154                      /* Failed to read/skip the required amount, so fail */
   1.155                      return -1;
   1.156 @@ -1092,21 +1107,23 @@
   1.157      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
   1.158      JNIEnv* env = Android_JNI_GetEnv();
   1.159      jobject retval = NULL;
   1.160 +    jstring service;
   1.161 +    jmethodID mid;
   1.162 +    jobject context;
   1.163 +    jobject manager;
   1.164  
   1.165      if (!LocalReferenceHolder_Init(&refs, env)) {
   1.166          LocalReferenceHolder_Cleanup(&refs);
   1.167          return NULL;
   1.168      }
   1.169  
   1.170 -    jstring service = (*env)->NewStringUTF(env, name);
   1.171 -
   1.172 -    jmethodID mid;
   1.173 +    service = (*env)->NewStringUTF(env, name);
   1.174  
   1.175      mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext", "()Landroid/content/Context;");
   1.176 -    jobject context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
   1.177 +    context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
   1.178  
   1.179      mid = (*env)->GetMethodID(env, mActivityClass, "getSystemServiceFromUiThread", "(Ljava/lang/String;)Ljava/lang/Object;");
   1.180 -    jobject manager = (*env)->CallObjectMethod(env, context, mid, service);
   1.181 +    manager = (*env)->CallObjectMethod(env, context, mid, service);
   1.182  
   1.183      (*env)->DeleteLocalRef(env, service);
   1.184  
   1.185 @@ -1118,11 +1135,12 @@
   1.186  #define SETUP_CLIPBOARD(error) \
   1.187      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); \
   1.188      JNIEnv* env = Android_JNI_GetEnv(); \
   1.189 +    jobject clipboard; \
   1.190      if (!LocalReferenceHolder_Init(&refs, env)) { \
   1.191          LocalReferenceHolder_Cleanup(&refs); \
   1.192          return error; \
   1.193      } \
   1.194 -    jobject clipboard = Android_JNI_GetSystemServiceObject("clipboard"); \
   1.195 +    clipboard = Android_JNI_GetSystemServiceObject("clipboard"); \
   1.196      if (!clipboard) { \
   1.197          LocalReferenceHolder_Cleanup(&refs); \
   1.198          return error; \
   1.199 @@ -1133,14 +1151,17 @@
   1.200  
   1.201  int Android_JNI_SetClipboardText(const char* text)
   1.202  {
   1.203 +    /* Watch out for C89 scoping rules because of the macro */
   1.204      SETUP_CLIPBOARD(-1)
   1.205  
   1.206 -    jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "setText", "(Ljava/lang/CharSequence;)V");
   1.207 -    jstring string = (*env)->NewStringUTF(env, text);
   1.208 -    (*env)->CallVoidMethod(env, clipboard, mid, string);
   1.209 -    (*env)->DeleteGlobalRef(env, clipboard);
   1.210 -    (*env)->DeleteLocalRef(env, string);
   1.211 -
   1.212 +    /* Nest the following in a scope to avoid C89 declaration rules triggered by the macro */
   1.213 +    {
   1.214 +        jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "setText", "(Ljava/lang/CharSequence;)V");
   1.215 +        jstring string = (*env)->NewStringUTF(env, text);
   1.216 +        (*env)->CallVoidMethod(env, clipboard, mid, string);
   1.217 +        (*env)->DeleteGlobalRef(env, clipboard);
   1.218 +        (*env)->DeleteLocalRef(env, string);
   1.219 +    }
   1.220      CLEANUP_CLIPBOARD();
   1.221  
   1.222      return 0;
   1.223 @@ -1148,25 +1169,30 @@
   1.224  
   1.225  char* Android_JNI_GetClipboardText(void)
   1.226  {
   1.227 +    /* Watch out for C89 scoping rules because of the macro */
   1.228      SETUP_CLIPBOARD(SDL_strdup(""))
   1.229  
   1.230 -    jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "getText", "()Ljava/lang/CharSequence;");
   1.231 -    jobject sequence = (*env)->CallObjectMethod(env, clipboard, mid);
   1.232 -    (*env)->DeleteGlobalRef(env, clipboard);
   1.233 -    if (sequence) {
   1.234 -        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, sequence), "toString", "()Ljava/lang/String;");
   1.235 -        jstring string = (jstring)((*env)->CallObjectMethod(env, sequence, mid));
   1.236 -        const char* utf = (*env)->GetStringUTFChars(env, string, 0);
   1.237 -        if (utf) {
   1.238 -            char* text = SDL_strdup(utf);
   1.239 -            (*env)->ReleaseStringUTFChars(env, string, utf);
   1.240 +    /* Nest the following in a scope to avoid C89 declaration rules triggered by the macro */
   1.241 +    {
   1.242 +        jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "getText", "()Ljava/lang/CharSequence;");
   1.243 +        jobject sequence = (*env)->CallObjectMethod(env, clipboard, mid);
   1.244 +        (*env)->DeleteGlobalRef(env, clipboard);
   1.245 +        if (sequence) {
   1.246 +            jstring string;
   1.247 +            const char* utf;
   1.248 +            mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, sequence), "toString", "()Ljava/lang/String;");
   1.249 +            string = (jstring)((*env)->CallObjectMethod(env, sequence, mid));
   1.250 +            utf = (*env)->GetStringUTFChars(env, string, 0);
   1.251 +            if (utf) {
   1.252 +                char* text = SDL_strdup(utf);
   1.253 +                (*env)->ReleaseStringUTFChars(env, string, utf);
   1.254  
   1.255 -            CLEANUP_CLIPBOARD();
   1.256 +                CLEANUP_CLIPBOARD();
   1.257  
   1.258 -            return text;
   1.259 +                return text;
   1.260 +            }
   1.261          }
   1.262      }
   1.263 -
   1.264      CLEANUP_CLIPBOARD();    
   1.265  
   1.266      return SDL_strdup("");
   1.267 @@ -1174,10 +1200,13 @@
   1.268  
   1.269  SDL_bool Android_JNI_HasClipboardText(void)
   1.270  {
   1.271 +    jmethodID mid;
   1.272 +    jboolean has;
   1.273 +    /* Watch out for C89 scoping rules because of the macro */
   1.274      SETUP_CLIPBOARD(SDL_FALSE)
   1.275  
   1.276 -    jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "hasText", "()Z");
   1.277 -    jboolean has = (*env)->CallBooleanMethod(env, clipboard, mid);
   1.278 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, clipboard), "hasText", "()Z");
   1.279 +    has = (*env)->CallBooleanMethod(env, clipboard, mid);
   1.280      (*env)->DeleteGlobalRef(env, clipboard);
   1.281  
   1.282      CLEANUP_CLIPBOARD();
   1.283 @@ -1194,49 +1223,61 @@
   1.284  {
   1.285      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
   1.286      JNIEnv* env = Android_JNI_GetEnv();
   1.287 +    jmethodID mid;
   1.288 +    jobject context;
   1.289 +    jstring action;
   1.290 +    jclass cls;
   1.291 +    jobject filter;
   1.292 +    jobject intent;
   1.293 +    jstring iname;
   1.294 +    jmethodID imid;
   1.295 +    jstring bname;
   1.296 +    jmethodID bmid;
   1.297      if (!LocalReferenceHolder_Init(&refs, env)) {
   1.298          LocalReferenceHolder_Cleanup(&refs);
   1.299          return -1;
   1.300      }
   1.301  
   1.302 -    jmethodID mid;
   1.303  
   1.304      mid = (*env)->GetStaticMethodID(env, mActivityClass, "getContext", "()Landroid/content/Context;");
   1.305 -    jobject context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
   1.306 +    context = (*env)->CallStaticObjectMethod(env, mActivityClass, mid);
   1.307  
   1.308 -    jstring action = (*env)->NewStringUTF(env, "android.intent.action.BATTERY_CHANGED");
   1.309 +    action = (*env)->NewStringUTF(env, "android.intent.action.BATTERY_CHANGED");
   1.310  
   1.311 -    jclass cls = (*env)->FindClass(env, "android/content/IntentFilter");
   1.312 +    cls = (*env)->FindClass(env, "android/content/IntentFilter");
   1.313  
   1.314      mid = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;)V");
   1.315 -    jobject filter = (*env)->NewObject(env, cls, mid, action);
   1.316 +    filter = (*env)->NewObject(env, cls, mid, action);
   1.317  
   1.318      (*env)->DeleteLocalRef(env, action);
   1.319  
   1.320      mid = (*env)->GetMethodID(env, mActivityClass, "registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;");
   1.321 -    jobject intent = (*env)->CallObjectMethod(env, context, mid, NULL, filter);
   1.322 +    intent = (*env)->CallObjectMethod(env, context, mid, NULL, filter);
   1.323  
   1.324      (*env)->DeleteLocalRef(env, filter);
   1.325  
   1.326      cls = (*env)->GetObjectClass(env, intent);
   1.327  
   1.328 -    jstring iname;
   1.329 -    jmethodID imid = (*env)->GetMethodID(env, cls, "getIntExtra", "(Ljava/lang/String;I)I");
   1.330 +    imid = (*env)->GetMethodID(env, cls, "getIntExtra", "(Ljava/lang/String;I)I");
   1.331  
   1.332 +    /* Watch out for C89 scoping rules because of the macro */
   1.333  #define GET_INT_EXTRA(var, key) \
   1.334 +    int var; \
   1.335      iname = (*env)->NewStringUTF(env, key); \
   1.336 -    int var = (*env)->CallIntMethod(env, intent, imid, iname, -1); \
   1.337 +    var = (*env)->CallIntMethod(env, intent, imid, iname, -1); \
   1.338      (*env)->DeleteLocalRef(env, iname);
   1.339  
   1.340 -    jstring bname;
   1.341 -    jmethodID bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z");
   1.342 +    bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z");
   1.343  
   1.344 +    /* Watch out for C89 scoping rules because of the macro */
   1.345  #define GET_BOOL_EXTRA(var, key) \
   1.346 +    int var; \
   1.347      bname = (*env)->NewStringUTF(env, key); \
   1.348 -    int var = (*env)->CallBooleanMethod(env, intent, bmid, bname, JNI_FALSE); \
   1.349 +    var = (*env)->CallBooleanMethod(env, intent, bmid, bname, JNI_FALSE); \
   1.350      (*env)->DeleteLocalRef(env, bname);
   1.351  
   1.352      if (plugged) {
   1.353 +        /* Watch out for C89 scoping rules because of the macro */
   1.354          GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */
   1.355          if (plug == -1) {
   1.356              LocalReferenceHolder_Cleanup(&refs);
   1.357 @@ -1248,6 +1289,7 @@
   1.358      }
   1.359  
   1.360      if (charged) {
   1.361 +        /* Watch out for C89 scoping rules because of the macro */
   1.362          GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */
   1.363          if (status == -1) {
   1.364              LocalReferenceHolder_Cleanup(&refs);
   1.365 @@ -1267,8 +1309,20 @@
   1.366      }
   1.367  
   1.368      if (percent) {
   1.369 -        GET_INT_EXTRA(level, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */
   1.370 -        GET_INT_EXTRA(scale, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */
   1.371 +        int level;
   1.372 +        int scale;
   1.373 +        
   1.374 +        /* Watch out for C89 scoping rules because of the macro */
   1.375 +        {
   1.376 +            GET_INT_EXTRA(level_temp, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */
   1.377 +            level = level_temp;
   1.378 +        }
   1.379 +        /* Watch out for C89 scoping rules because of the macro */
   1.380 +        {
   1.381 +            GET_INT_EXTRA(scale_temp, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */
   1.382 +            scale = scale_temp;
   1.383 +        }
   1.384 +        
   1.385          if ((level == -1) || (scale == -1)) {
   1.386              LocalReferenceHolder_Cleanup(&refs);
   1.387              return -1;
   1.388 @@ -1321,14 +1375,16 @@
   1.389  int Android_JNI_SendMessage(int command, int param)
   1.390  {
   1.391      JNIEnv *env = Android_JNI_GetEnv();
   1.392 +    jmethodID mid;
   1.393 +    jboolean success;
   1.394      if (!env) {
   1.395          return -1;
   1.396      }
   1.397 -    jmethodID mid = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z");
   1.398 +    mid = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z");
   1.399      if (!mid) {
   1.400          return -1;
   1.401      }
   1.402 -    jboolean success = (*env)->CallStaticBooleanMethod(env, mActivityClass, mid, command, param);
   1.403 +    success = (*env)->CallStaticBooleanMethod(env, mActivityClass, mid, command, param);
   1.404      return success ? 0 : -1;
   1.405  }
   1.406  
   1.407 @@ -1340,11 +1396,12 @@
   1.408  void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
   1.409  {
   1.410      JNIEnv *env = Android_JNI_GetEnv();
   1.411 +    jmethodID mid;
   1.412      if (!env) {
   1.413          return;
   1.414      }
   1.415  
   1.416 -    jmethodID mid = (*env)->GetStaticMethodID(env, mActivityClass, "showTextInput", "(IIII)Z");
   1.417 +    mid = (*env)->GetStaticMethodID(env, mActivityClass, "showTextInput", "(IIII)Z");
   1.418      if (!mid) {
   1.419          return;
   1.420      }
     2.1 --- a/src/joystick/android/SDL_sysjoystick.c	Mon Feb 08 01:08:21 2016 -0500
     2.2 +++ b/src/joystick/android/SDL_sysjoystick.c	Tue Feb 09 17:36:42 2016 -0800
     2.3 @@ -323,6 +323,7 @@
     2.4  {
     2.5      SDL_joylist_item *item = SDL_joylist;
     2.6      SDL_joylist_item *prev = NULL;
     2.7 +    int retval;
     2.8  #if !SDL_EVENTS_DISABLED
     2.9      SDL_Event event;
    2.10  #endif
    2.11 @@ -340,7 +341,7 @@
    2.12          return -1;
    2.13      }
    2.14  
    2.15 -    const int retval = item->device_instance;
    2.16 +    retval = item->device_instance;
    2.17      if (item->joystick) {
    2.18          item->joystick->hwdata = NULL;
    2.19      }
     3.1 --- a/src/main/android/SDL_android_main.c	Mon Feb 08 01:08:21 2016 -0500
     3.2 +++ b/src/main/android/SDL_android_main.c	Tue Feb 09 17:36:42 2016 -0800
     3.3 @@ -22,6 +22,8 @@
     3.4      int i;
     3.5      int argc;
     3.6      int status;
     3.7 +    int len;
     3.8 +    char** argv;
     3.9  
    3.10      /* This interface could expand with ABI negotiation, callbacks, etc. */
    3.11      SDL_Android_Init(env, cls);
    3.12 @@ -30,8 +32,8 @@
    3.13  
    3.14      /* Prepare the arguments. */
    3.15  
    3.16 -    int len = (*env)->GetArrayLength(env, array);
    3.17 -    char* argv[1 + len + 1];
    3.18 +    len = (*env)->GetArrayLength(env, array);
    3.19 +    argv = SDL_stack_alloc(char*, 1 + len + 1);
    3.20      argc = 0;
    3.21      /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
    3.22         https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
    3.23 @@ -66,7 +68,7 @@
    3.24      for (i = 0; i < argc; ++i) {
    3.25          SDL_free(argv[i]);
    3.26      }
    3.27 -
    3.28 +    SDL_stack_free(argv);
    3.29      /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
    3.30      /* exit(status); */
    3.31