Fixed bug 4315 - little Warning in Android_JNI_CaptureAudioBuffer
authorSam Lantinga <slouken@libsdl.org>
Fri, 02 Nov 2018 17:18:03 -0700
changeset 123872f02c753a5dc
parent 12386 a80816d0e9d2
child 12388 69af2eac84e9
Fixed bug 4315 - little Warning in Android_JNI_CaptureAudioBuffer

Sylvain

SDL_android.c
src/core/android/SDL_android.c:1302:5: warning: variable 'br' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
default:
^~~~~~~
src/core/android/SDL_android.c:1306:12: note: uninitialized use occurs here
return br;
^~
src/core/android/SDL_android.c:1270:12: note: initialize the variable 'br' to silence this warning
jint br;
^


Maybe we could add some basics warning flags, not to see all warnings, but so that new warnings are caught sooner.

I would go for -Wall -Wextra, and some -Wno-warning for the allowed warnings.
Android.mk
src/core/android/SDL_android.c
     1.1 --- a/Android.mk	Fri Oct 12 22:05:58 2018 -0700
     1.2 +++ b/Android.mk	Fri Nov 02 17:18:03 2018 -0700
     1.3 @@ -53,6 +53,22 @@
     1.4  LOCAL_SHARED_LIBRARIES := hidapi
     1.5  
     1.6  LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
     1.7 +LOCAL_CFLAGS += \
     1.8 +	-Wall -Wextra \
     1.9 +	-Wdocumentation \
    1.10 +	-Wdocumentation-unknown-command \
    1.11 +	-Wmissing-prototypes \
    1.12 +	-Wunreachable-code-break \
    1.13 +	-Wunneeded-internal-declaration \
    1.14 +	-Wmissing-variable-declarations \
    1.15 +	-Wfloat-conversion \
    1.16 +	-Wshorten-64-to-32 \
    1.17 +	-Wunreachable-code-return
    1.18 +
    1.19 +# Warnings we haven't fixed (yet)
    1.20 +LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
    1.21 + 
    1.22 +
    1.23  LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
    1.24  
    1.25  ifeq ($(NDK_DEBUG),1)
     2.1 --- a/src/core/android/SDL_android.c	Fri Oct 12 22:05:58 2018 -0700
     2.2 +++ b/src/core/android/SDL_android.c	Fri Nov 02 17:18:03 2018 -0700
     2.3 @@ -1261,7 +1261,7 @@
     2.4  {
     2.5      JNIEnv *env = Android_JNI_GetEnv();
     2.6      jboolean isCopy = JNI_FALSE;
     2.7 -    jint br;
     2.8 +    jint br = -1;
     2.9  
    2.10      switch (captureBufferFormat) {
    2.11      case ENCODING_PCM_8BIT: