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 - little Warning in Android_JNI_CaptureAudioBuffer
Summary: little Warning in Android_JNI_CaptureAudioBuffer
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: don't know
Hardware: All Android (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-15 16:29 UTC by Sylvain
Modified: 2018-11-03 00:18 UTC (History)
0 users

See Also:


Attachments
patch (1.06 KB, patch)
2018-10-16 14:15 UTC, Sylvain
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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