From fad2c7b3c1863ad28c8f1492c91bb89ad0bb3168 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 28 Sep 2022 07:21:39 -0700 Subject: [PATCH] add assert and a debugging aid --- xwords4/android/jni/xwjni.c | 16 +++++++++++++--- xwords4/common/comms.c | 1 - xwords4/common/movestak.c | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index f5c48f1d1..0d90cb94b 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -929,7 +929,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_nli_1from_1stream jnli = makeObjectEmptyConst( env, PKG_PATH("NetLaunchInfo") ); setNLI( env, jnli, &nli ); } else { - XP_LOGFF( "game_makeFromStream failed" ); + XP_LOGFF( "nli_makeFromStream failed" ); } stream_destroy( stream, env ); @@ -1303,8 +1303,17 @@ struct _JNIState { }; #define GAME_GUARD 0x453627 +#if 0 +# define LOG_FUNC_IF() LOG_FUNC() +# define LOG_RETURN_VOID_IF() LOG_RETURN_VOID() +#else +# define LOG_FUNC_IF() +# define LOG_RETURN_VOID_IF() +#endif + #define XWJNI_START() { \ JNIState* state = getState( env, gamePtr, __func__ ); \ + LOG_FUNC_IF(); \ XP_ASSERT( state->guard == GAME_GUARD ); \ MPSLOT; \ MPASSIGN( mpool, state->mpool ); \ @@ -1316,8 +1325,9 @@ struct _JNIState { AndGameGlobals* globals = &state->globals; \ XP_USE(globals); /*no warnings */ \ -#define XWJNI_END() \ - } \ +#define XWJNI_END() \ + LOG_RETURN_VOID_IF(); \ + } \ JNIEXPORT jlong JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_gameJNIInit diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index da69a8725..af3cdc963 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -938,7 +938,6 @@ comms_stop( CommsCtxt* comms #endif ) { - LOG_FUNC(); if ( addr_hasType( &comms->selfAddr, COMMS_CONN_RELAY ) ) { relayDisconnect( comms, xwe ); } diff --git a/xwords4/common/movestak.c b/xwords4/common/movestak.c index 8d4ea1620..1d6f02bd2 100644 --- a/xwords4/common/movestak.c +++ b/xwords4/common/movestak.c @@ -163,6 +163,7 @@ stack_loadFromStream( StackCtxt* stack, XWStreamCtxt* stream ) if ( STREAM_VERS_NINETILES <= stream_getVersion(stream) ) { stackVersion = stream_getU8( stream ); XP_LOGFF( "read stackVersion: %d from stream", stackVersion ); + XP_ASSERT( stackVersion <= CUR_STREAM_VERS ); } stack->highWaterMark = stream_getU16( stream ); stack->nEntries = stream_getU16( stream );