From 00984b7ab99e3129f1a8aeaddd3d50157e0bf65e Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sun, 27 Oct 2019 13:09:46 -0700 Subject: [PATCH] Compile on Android with more warnings --- Android/jni/jnihooks.c | 2 +- Android/jni/sources.mk | 2 +- src/audio/soundcore-opensles.c | 7 +++++-- src/common.h | 21 +++++++++++++++++++++ src/joystick.c | 2 ++ src/video/gltouchjoy.c | 4 ---- src/video/gltouchjoy_joy.c | 1 - src/video/gltouchjoy_kpad.c | 1 - src/video/glvideo.c | 3 +++ 9 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Android/jni/jnihooks.c b/Android/jni/jnihooks.c index 76c1ec75..d1c6924c 100644 --- a/Android/jni/jnihooks.c +++ b/Android/jni/jnihooks.c @@ -442,7 +442,7 @@ void Java_org_deadc0de_apple2ix_Apple2DisksMenu_nativeEjectDisk(JNIEnv *env, jcl disk6_eject(driveA ? 0 : 1); } -static int _openFdFromJson(OUTPARM int *fdOut, JSON_ref jsonData, const char * const fdKey, const char * const pathKey, int flags, int mode) { +static void _openFdFromJson(OUTPARM int *fdOut, JSON_ref jsonData, const char * const fdKey, const char * const pathKey, int flags, int mode) { long fd = -1; char *path = NULL; diff --git a/Android/jni/sources.mk b/Android/jni/sources.mk index 533a6b11..6f7d38aa 100644 --- a/Android/jni/sources.mk +++ b/Android/jni/sources.mk @@ -64,7 +64,7 @@ APPLE2_MAIN_SRC = \ $(APPLE2_SRC_PATH)/../externals/jsmn/jsmn.c APPLE2_OPTIM_CFLAGS := -O2 # match the same optimization level as BUILD_MODE=release for ndk-build -APPLE2_BASE_CFLAGS := -DAPPLE2IX=1 -DINTERFACE_TOUCH=1 -DMOBILE_DEVICE=1 -DVIDEO_OPENGL=1 -std=gnu11 -fPIC $(APPLE2_OPTIM_CFLAGS) -I$(APPLE2_SRC_PATH) +APPLE2_BASE_CFLAGS := -Wall -DAPPLE2IX=1 -DINTERFACE_TOUCH=1 -DMOBILE_DEVICE=1 -DVIDEO_OPENGL=1 -std=gnu11 -fPIC $(APPLE2_OPTIM_CFLAGS) -I$(APPLE2_SRC_PATH) APPLE2_BASE_LDLIBS := -Wl,-z,text -Wl,-z,noexecstack -llog -landroid -lGLESv2 -lz -lOpenSLES -latomic LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures diff --git a/src/audio/soundcore-opensles.c b/src/audio/soundcore-opensles.c index baeefb99..ef456356 100644 --- a/src/audio/soundcore-opensles.c +++ b/src/audio/soundcore-opensles.c @@ -63,7 +63,7 @@ typedef struct EngineContext_s { } EngineContext_s; -static AudioBackend_s opensles_audio_backend = { 0 }; +static AudioBackend_s opensles_audio_backend = { { 0 } }; // ---------------------------------------------------------------------------- // AudioBuffer_s internal processing routines @@ -230,6 +230,8 @@ static long SLGetPosition(AudioBuffer_s *_this, OUTPARM unsigned long *bytes_que assert(workingBytes <= voice->bufferSize); *bytes_queued = workingBytes; + + (void)queuedBytes; } while (0); return err; @@ -729,6 +731,7 @@ static long opensles_systemPause(AudioContext_s *audio_context) { EngineContext_s *ctx = (EngineContext_s *)(audio_context->_internal); SLresult result = (*(ctx->bqPlayerPlay))->SetPlayState(ctx->bqPlayerPlay, SL_PLAYSTATE_PAUSED); + (void)result; return 0; } @@ -751,7 +754,7 @@ static long opensles_systemResume(AudioContext_s *audio_context) { if (state == SL_PLAYSTATE_PAUSED) { // Balanced resume OK here - SLresult result = (*(ctx->bqPlayerPlay))->SetPlayState(ctx->bqPlayerPlay, SL_PLAYSTATE_PLAYING); + result = (*(ctx->bqPlayerPlay))->SetPlayState(ctx->bqPlayerPlay, SL_PLAYSTATE_PLAYING); } else if (state == SL_PLAYSTATE_STOPPED) { // Do not resume for stopped state, let this get forced from CPU/speaker thread otherwise we starve. (The // stopped state happens if user dynamically changed buffer parameters in menu settings which triggered an diff --git a/src/common.h b/src/common.h index 757c8dd4..f2ac4de0 100644 --- a/src/common.h +++ b/src/common.h @@ -173,5 +173,26 @@ _rc; }) #endif +#define _STRINGIFY(x) #x + +// diagnostic suppression +#if defined(__clang__) + // NOTE: check for Clang first, since it also defines __GNUC__ +# define DIAGNOSTIC_SUPPRESS_PUSH(clang_diag, gcc_diag) \ + _Pragma("clang diagnostic push") \ + _Pragma(_STRINGIFY(clang diagnostic ignored clang_diag)) +# define DIAGNOSTIC_SUPPRESS_POP() \ + _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +# define DIAGNOSTIC_SUPPRESS_PUSH(clang_diag, gcc_diag) \ + _Pragma("GCC diagnostic push") \ + _Pragma(_STRINGIFY(GCC diagnostic ignored gcc_diag)) + +# define DIAGNOSTIC_SUPPRESS_POP() \ + _Pragma("GCC diagnostic pop") +#else +# error "unknown possibly unsupported compiler!" +#endif #endif // whole file + diff --git a/src/joystick.c b/src/joystick.c index 8429e0d6..dc9cda01 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -269,6 +269,7 @@ void c_calibrate_joystick() } #endif // INTERFACE_CLASSIC +#if !TESTING // HACK : avoid resetting joystick button values too quickly. This should allow for ClosedApple-Reset. (This is still a // race, but hopefully much less likely to trigger). static void *_joystick_resetDelayed(void *ctx) { @@ -283,6 +284,7 @@ static void *_joystick_resetDelayed(void *ctx) { return NULL; } +#endif void c_joystick_reset(void) { diff --git a/src/video/gltouchjoy.c b/src/video/gltouchjoy.c index 72e4d015..297b4962 100644 --- a/src/video/gltouchjoy.c +++ b/src/video/gltouchjoy.c @@ -642,10 +642,6 @@ static void gltouchjoy_reshape(int w, int h, bool landscape) { } } -static void gltouchjoy_resetJoystick(void) { - // no-op -} - static inline bool _is_point_on_axis_side(int x, int y) { return (x >= touchport.axisX && x <= touchport.axisXMax && y >= touchport.axisY && y <= touchport.axisYMax); } diff --git a/src/video/gltouchjoy_joy.c b/src/video/gltouchjoy_joy.c index 61bb9eb3..81c3fb67 100644 --- a/src/video/gltouchjoy_joy.c +++ b/src/video/gltouchjoy_joy.c @@ -251,7 +251,6 @@ static void touchjoy_buttonUp(int dx, int dy) { SPIN_LOCK_FULL(&joys.spinlock); TOUCH_JOY_LOG("\t\tjoy buttonUp acquire"); - bool ignored = false; _touchjoy_buttonMove(dx, dy); _fire_current_buttons(); diff --git a/src/video/gltouchjoy_kpad.c b/src/video/gltouchjoy_kpad.c index 60181520..34c18e0a 100644 --- a/src/video/gltouchjoy_kpad.c +++ b/src/video/gltouchjoy_kpad.c @@ -618,7 +618,6 @@ static void _subvariant_prefsChanged(subvariant_s *subvariant, const char *domai static void touchkpad_prefsChanged(const char *domain) { assert(video_isRenderThread()); - long lVal = 0; bool bVal = false; kpad.autostrobeDelay = !(prefs_parseBoolValue(domain, PREF_KPAD_FAST_AUTOREPEAT, &bVal) ? bVal : true); diff --git a/src/video/glvideo.c b/src/video/glvideo.c index 174dacd1..56307c87 100644 --- a/src/video/glvideo.c +++ b/src/video/glvideo.c @@ -254,6 +254,7 @@ static void glvideo_init(void) { // Check for errors to make sure all of our setup went ok GL_MAYBELOG("finished initialization"); + DIAGNOSTIC_SUPPRESS_PUSH("-Waddress", "-Waddress") #if __APPLE__ if (1) { #else @@ -264,6 +265,7 @@ static void glvideo_init(void) { ERRQUIT("framebuffer status: %04X", status); } } + DIAGNOSTIC_SUPPRESS_POP() } static void glvideo_shutdown(void) { @@ -358,6 +360,7 @@ static void glvideo_render(void) { #if !FB_PIXELS_PASS_THRU memcpy(/*dest:*/crtModel->texPixels, /*src:*/fb, (SCANWIDTH*SCANHEIGHT*sizeof(PIXEL_TYPE))); #endif + (void)fb; glTexImage2D(GL_TEXTURE_2D, /*level*/0, TEX_FORMAT_INTERNAL, SCANWIDTH, SCANHEIGHT, /*border*/0, TEX_FORMAT, TEX_TYPE, crtModel->texPixels); }