We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4315

Summary: little Warning in Android_JNI_CaptureAudioBuffer
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: All   
OS: Android (All)   
Attachments: patch

Description Sylvain 2018-10-15 16:29:26 UTC
A little Warning in Android_JNI_CaptureAudioBuffer.

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.
Comment 1 Ozkan Sezer 2018-10-15 16:41:32 UTC
(In reply to Sylvain from comment #0)
> A little Warning in Android_JNI_CaptureAudioBuffer.
> 
> SDL_android.c
> src/core/android/SDL_android.c:1302:5: warning: variable 'br' is used

It is not that 'little', because the warning is not 'maybe used'
butt 'is used' unitialized, and indeed it is.
Comment 2 Sylvain 2018-10-16 14:15:45 UTC
Created attachment 3375 [details]
patch

Here's a patch.

This is in Android/JNI CaptureFromDevice.
So let's make this default value be an error !

It's default behaviour, handled correctly by generic audio layer: https://hg.libsdl.org/SDL/file/43d46306c3ba/src/audio/SDL_audio.c#l835


Moreover, the patch also contains my warning suggestion to add in Android.mk :

+LOCAL_CFLAGS += \
+	-Wall -Wextra \
+	-Wdocumentation \
+	-Wdocumentation-unknown-command \
+	-Wmissing-prototypes \
+	-Wunreachable-code-break \
+	-Wunneeded-internal-declaration \
+	-Wmissing-variable-declarations \
+	-Wfloat-conversion \
+	-Wshorten-64-to-32 \
+	-Wunreachable-code-return
+
+# Warnings we haven't fixed (yet)
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
+ 


It add a only few warnings that could be fixed in future. The build log won't get flooded.
Comment 3 Sam Lantinga 2018-11-03 00:18:20 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/2f02c753a5dc